From 1c10e60943c2e5c2dc3f010a63e02001201db83b Mon Sep 17 00:00:00 2001 From: Greg Hendershott Date: Fri, 2 Nov 2012 08:35:40 -0400 Subject: [PATCH] More small edits --- main.rkt | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/main.rkt b/main.rkt index 60f3b56..6826a04 100644 --- a/main.rkt +++ b/main.rkt @@ -768,7 +768,8 @@ that using an additional, nested @racket[syntax-case]: (syntax-case stx () [(_ a b (args ...) body0 body ...) (syntax-case (datum->syntax stx - (string->symbol (format "~a-~a" #'a #'b))) () + (string->symbol (format "~a-~a" #'a #'b))) + () [name #'(define (name args ...) body0 body ...)])])) ] @@ -794,23 +795,19 @@ Let's try to use our new version: Hmm. @racket[foo-bar] is @italic{still} not defined. Back to the Macro Stepper. It says now we're expanding to: -@racketblock[ -(define (|#-#|) #t) -] +@racketblock[(define (|#-#|) #t)] Oh right: @racket[#'a] and @racket[#'b] are syntax objects. Therefore @racketblock[(string->symbol (format "~a-~a" #'a #'b))] -is something like +is the printed form of both syntax objects, joined by a hyphen: @racketblock[|#-#|] ----the printed form of both syntax objects, joined by a hyphen. - -Instead we want the datum in the syntax objects (such as the symbols -@racket[foo] and @racket[bar]). Let's use @racket[syntax->datum] to -get it: +Instead we want the datum in the syntax objects, such as the symbols +@racket[foo] and @racket[bar]. Which we get using +@racket[syntax->datum]: @i[ (define-syntax (hyphen-define/ok1 stx) @@ -819,7 +816,8 @@ get it: (syntax-case (datum->syntax stx (string->symbol (format "~a-~a" (syntax->datum #'a) - (syntax->datum #'b)))) () + (syntax->datum #'b)))) + () [name #'(define (name args ...) body0 body ...)])])) (hyphen-define/ok1 foo bar () #t)