(rapid quasiquote)

Extended quasiquotation with ellipses.

Introduction

This library defines an extension to quasiquote that allows ellipses to be used in place of unquote-splicing, which often leads to more readable code.

Examples

The basic usage of quasiquote is the same as in the R7RS:
`(list ,(+ 1 2) 4)
=> (list 3 4)
Lists can still be spliced into sequences.
`(a ,(+ 1 2) ,@(map abs '(4 -5 6)) b)
=> (a 3 4 5 6 b)
The extension to quasiquote allows ellipses to be used in place of unquote-splicing (,@) to piece together the output form.
`(a ,(+ 1 2) ,(map abs '(4 -5 6)) ... b)
=> (a 3 4 5 6 b)
Within each subform followed by an ellipsis, each comma-prefixed item must be a list and all such items within the same subform must have the same length.
`((,'(1 2 3) . ,'(a b c)) ...)
=> ((1 . a) (2 . b) (3 . c))
A subform followed by an ellipsis may be contained with a larger subform that is also followed by an ellipsis. In this case, each comma-prefixed item must be a list of lists, each such item must have the same length, and the corresponding sublists of each such item must have the same lengths. This requirement generalizes to comma-prefixed items nested within more than two levels of ellipsis-followed subforms.
`(((a ,'((x 1) (x 2) (x 3))) ...) ...)
=> (((a x) (a 1)) ((a x) (a 2)) ((a x) (a 3)))
In the output, a subform may be followed directly by two or more ellipses; the requirements are the same as for nested ellipses, but the result is flattened rather than nested.
`((a ,'((x 1) (x 2) (x 3))) ... ...)
=> ((a x) (a 1) (a x) (a 2) (a x) (a 3))
Ellipses can also follow subforms containing items prefixed by comma-at.
`((a ,@'((x 1) (x 2) (x 3))) ...)
=> ((a x 1) (a x 2) (a x 3))
A subform of the form (... form) is identical to form, except that ellipses in the subform have no special meaning.
`(... (,'(1 2 3) ...))
=> ((1 2 3) ...)
Substitutions are made only for unquoted components appearing at the same nesting level as the outermost quasiquote.
`(a `(b ,(list 1 2) ... ,(foo ,(list 1 3) ... d) e) f)
=> (a (quasiquote (b (unquote (list 1 2)) ... (unquote (foo 1 3 d)) e)) f)

Syntax

(quasiquote form)

`form

If no instances of the ellipsis ... appear within the form at the same nesting level as the outmost quasiquote, the result of evaluating `form is the same as if quasiquote from (scheme base) was used. A subform of the form (... form) is identical to form, except that ellipses within the subtemplate have no special meaning. If a subform is followed by one or more instances of the ellipsis, the expressions following a comma have to evaluate into nested lists of the same or higher nesting depths. They are replaced in the output by all of the elements they match in the input, distributed as indicated. It is an error if the output cannot be built up as specified.

Auxiliary syntax

unquote

, unquote-splicing

,@ ...

Syntax bindings equivalent to those in (scheme base).