Extended quasiquotation with ellipses.
This library defines an extension toquasiquote
that allows
ellipses to be used in place of unquote-splicing
, which
often leads to more readable code.
The basic usage of quasiquote
is the same as in the R7RS:
`(list ,(+ 1 2) 4)
=> (list 3 4)
`(a ,(+ 1 2) ,@(map abs '(4 -5 6)) b)
=> (a 3 4 5 6 b)
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)
`((,'(1 2 3) . ,'(a b c)) ...)
=> ((1 . a) (2 . b) (3 . c))
`(((a ,'((x 1) (x 2) (x 3))) ...) ...)
=> (((a x) (a 1)) ((a x) (a 2)) ((a x) (a 3)))
`((a ,'((x 1) (x 2) (x 3))) ... ...)
=> ((a x) (a 1) (a x) (a 2) (a x) (a 3))
`((a ,@'((x 1) (x 2) (x 3))) ...)
=> ((a x 1) (a x 2) (a x 3))
(... form)
is identical to
form
, except that ellipses in the subform have no special
meaning.
`(... (,'(1 2 3) ...))
=> ((1 2 3) ...)
`(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)
...
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.
Syntax bindings equivalent to those in (scheme base)
.