liberalize un{quote,syntax}-spliciing to allow a non-list at the end of an enclosing list
svn: r8083
This commit is contained in:
parent
b8b7a1bb0d
commit
d794bde875
|
@ -275,9 +275,10 @@
|
|||
(if (zero? level)
|
||||
(let-values
|
||||
(((l) (normal l old-l)))
|
||||
(let-values
|
||||
()
|
||||
(list (quote-syntax qq-append) uqsd l)))
|
||||
(if (stx-null? l)
|
||||
uqsd
|
||||
(list (quote-syntax qq-append)
|
||||
uqsd l)))
|
||||
(let-values
|
||||
(((restx) (qq-list rest (sub1 level))))
|
||||
(let-values
|
||||
|
|
|
@ -66,6 +66,13 @@
|
|||
stx)]
|
||||
[((unsyntax-splicing x) . rest)
|
||||
(if (zero? depth)
|
||||
(if (stx-null? (syntax rest))
|
||||
(with-syntax ([temp (car (generate-temporaries '(uqs1)))])
|
||||
(convert-k (datum->syntax
|
||||
stx
|
||||
(syntax temp)
|
||||
stx)
|
||||
(list #'[temp x])))
|
||||
(let ([rest-done-k
|
||||
(lambda (rest-v bindings)
|
||||
(with-syntax ([temp (car (generate-temporaries '(uqs)))]
|
||||
|
@ -81,7 +88,7 @@
|
|||
(loop (syntax rest) depth
|
||||
(lambda ()
|
||||
(rest-done-k (syntax rest) null))
|
||||
rest-done-k))
|
||||
rest-done-k)))
|
||||
(let ([mk-rest-done-k
|
||||
(lambda (x-v x-bindings)
|
||||
(lambda (rest-v rest-bindings)
|
||||
|
|
|
@ -33,7 +33,7 @@ Creates an empty font list.
|
|||
[underline any/c #f]
|
||||
[smoothing (one-of/c 'default 'partly-smoothed 'smoothed 'unsmoothed) 'default]
|
||||
[size-in-pixels? any/c #f])
|
||||
void?])]{
|
||||
(is-a?/c font%)])]{
|
||||
|
||||
Finds an existing font in the list or creates a new one (that is
|
||||
automatically added to the list). The arguments are the same as for
|
||||
|
|
|
@ -1013,12 +1013,18 @@ and the result of the @scheme[_expr] takes the place of the
|
|||
@scheme[(unquote-splicing _expr)] similarly escapes, but the
|
||||
@scheme[_expr] must produce a list, and its elements are spliced as
|
||||
multiple values place of the @scheme[(unquote-splicing _expr)], which
|
||||
must appear as the @scheme[car] or a quoted pair.
|
||||
must appear as the @scheme[car] or a quoted pair; if the @scheme[cdr]
|
||||
of the relevant quoted pair is empty, then @scheme[_expr] need not
|
||||
produce a list, and its result is used directly in place of the quoted
|
||||
pair (in the same way that @scheme[append] accepts a non-list final
|
||||
argument).
|
||||
|
||||
@examples[
|
||||
(eval:alts (#,(scheme quasiquote) (0 1 2)) `(0 1 2))
|
||||
(eval:alts (#,(scheme quasiquote) (0 (#,(scheme unquote) (+ 1 2)) 4)) `(1 ,(+ 1 2) 4))
|
||||
(eval:alts (#,(scheme quasiquote) (0 (#,(scheme unquote-splicing) (list 1 2)) 4)) `(1 ,@(list 1 2) 4))
|
||||
(eval:alts (#,(scheme quasiquote) (0 (#,(scheme unquote) (+ 1 2)) 4)) `(0 ,(+ 1 2) 4))
|
||||
(eval:alts (#,(scheme quasiquote) (0 (#,(scheme unquote-splicing) (list 1 2)) 4)) `(0 ,@(list 1 2) 4))
|
||||
(eval:alts (#,(scheme quasiquote) (0 (#,(scheme unquote-splicing) 1) 4)) `(0 ,@1 4))
|
||||
(eval:alts (#,(scheme quasiquote) (0 (#,(scheme unquote-splicing) 1))) `(0 ,@1))
|
||||
]
|
||||
|
||||
A @scheme[quasiquote], @scheme[unquote], or @scheme[unquote-splicing]
|
||||
|
|
|
@ -663,7 +663,7 @@
|
|||
(syntax-test #'(unquote-splicing 7))
|
||||
|
||||
(syntax-test #'`(1 . ,@5))
|
||||
(error-test #'`(1 ,@5))
|
||||
(test (cons 1 5) 'qq `(1 ,@5))
|
||||
(error-test #'`(1 ,@5 2))
|
||||
|
||||
(define (qq-test e)
|
||||
|
|
Loading…
Reference in New Issue
Block a user