simpify an example
This commit is contained in:
parent
7a2e1aa900
commit
a8c0c1f8b7
|
@ -240,26 +240,24 @@ generated value onto that list.
|
||||||
@transform-time[]
|
@transform-time[]
|
||||||
|
|
||||||
@examples[#:eval stx-eval
|
@examples[#:eval stx-eval
|
||||||
(define-syntax do-print
|
(define-syntax-rule (do-print x ...)
|
||||||
(syntax-rules ()
|
(printf x ...))
|
||||||
[(_ x ...) (printf x ...)]))
|
|
||||||
|
|
||||||
(define-syntax hello
|
(define-syntax-rule (hello x)
|
||||||
(syntax-rules ()
|
(do-print "hello ~a" x))
|
||||||
[(_ x) (do-print "hello ~a" x)]))
|
|
||||||
|
|
||||||
(define-syntax (show stx)
|
(define-syntax (show stx)
|
||||||
(syntax-case stx ()
|
(syntax-case stx ()
|
||||||
[(_ x)
|
[(_ x)
|
||||||
(with-syntax ([partly-expanded (local-expand #'(hello x)
|
(let ([partly (local-expand #'(hello x)
|
||||||
'expression
|
'expression
|
||||||
(list #'do-print))]
|
(list #'do-print))]
|
||||||
[expanded (local-expand #'(hello x)
|
[fully (local-expand #'(hello x)
|
||||||
'expression
|
'expression
|
||||||
#f)])
|
#f)])
|
||||||
(printf "partly expanded syntax is ~a\n" (syntax->datum #'partly-expanded))
|
(printf "partly expanded: ~s\n" (syntax->datum partly))
|
||||||
(printf "expanded syntax is ~a\n" (syntax->datum #'expanded))
|
(printf "fully expanded: ~s\n" (syntax->datum fully))
|
||||||
#'expanded)]))
|
fully)]))
|
||||||
|
|
||||||
(show 1)
|
(show 1)
|
||||||
]}
|
]}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user