From 58424ecdcc40bcdef1d59eccea521271abd7cee2 Mon Sep 17 00:00:00 2001 From: Jon Rafkind Date: Tue, 30 Jun 2009 21:37:52 +0000 Subject: [PATCH] add example for local-expand svn: r15347 --- .../scribblings/reference/stx-trans.scrbl | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/collects/scribblings/reference/stx-trans.scrbl b/collects/scribblings/reference/stx-trans.scrbl index 65e8d3de09..1e4b26fa85 100644 --- a/collects/scribblings/reference/stx-trans.scrbl +++ b/collects/scribblings/reference/stx-trans.scrbl @@ -198,7 +198,32 @@ was triggered by a use of a module-defined identifier with a expanded for the body of a module, then the expansion of @scheme[stx] can use any identifier defined by the module. -@transform-time[]} +@transform-time[] + +@examples[#:eval stx-eval +(define-syntax do-print + (syntax-rules () + [(_ x ...) (printf x ...)])) + +(define-syntax hello + (syntax-rules () + [(_ x) (do-print "hello ~a" x)])) + +(define-syntax (show stx) + (syntax-case stx () + [(_ x) + (with-syntax ([partly-expanded (local-expand #'(hello x) + 'expression + (list #'do-print))] + [expanded (local-expand #'(hello x) + 'expression + #f)]) + (printf "partly expanded syntax is ~a\n" (syntax->datum #'partly-expanded)) + (printf "expanded syntax is ~a\n" (syntax->datum #'expanded)) + #'expanded)])) + +(show 1) +]} @defproc[(syntax-local-expand-expression [stx syntax?])