More small edits
This commit is contained in:
parent
bf7c9f0ace
commit
1c10e60943
20
main.rkt
20
main.rkt
|
@ -768,7 +768,8 @@ that using an additional, nested @racket[syntax-case]:
|
||||||
(syntax-case stx ()
|
(syntax-case stx ()
|
||||||
[(_ a b (args ...) body0 body ...)
|
[(_ a b (args ...) body0 body ...)
|
||||||
(syntax-case (datum->syntax stx
|
(syntax-case (datum->syntax stx
|
||||||
(string->symbol (format "~a-~a" #'a #'b))) ()
|
(string->symbol (format "~a-~a" #'a #'b)))
|
||||||
|
()
|
||||||
[name #'(define (name args ...)
|
[name #'(define (name args ...)
|
||||||
body0 body ...)])]))
|
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
|
Hmm. @racket[foo-bar] is @italic{still} not defined. Back to the Macro
|
||||||
Stepper. It says now we're expanding to:
|
Stepper. It says now we're expanding to:
|
||||||
|
|
||||||
@racketblock[
|
@racketblock[(define (|#<syntax:11:24foo>-#<syntax:11:28 bar>|) #t)]
|
||||||
(define (|#<syntax:11:24foo>-#<syntax:11:28 bar>|) #t)
|
|
||||||
]
|
|
||||||
|
|
||||||
Oh right: @racket[#'a] and @racket[#'b] are syntax objects. Therefore
|
Oh right: @racket[#'a] and @racket[#'b] are syntax objects. Therefore
|
||||||
|
|
||||||
@racketblock[(string->symbol (format "~a-~a" #'a #'b))]
|
@racketblock[(string->symbol (format "~a-~a" #'a #'b))]
|
||||||
|
|
||||||
is something like
|
is the printed form of both syntax objects, joined by a hyphen:
|
||||||
|
|
||||||
@racketblock[|#<syntax:11:24foo>-#<syntax:11:28 bar>|]
|
@racketblock[|#<syntax:11:24foo>-#<syntax:11:28 bar>|]
|
||||||
|
|
||||||
---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]. Which we get using
|
||||||
Instead we want the datum in the syntax objects (such as the symbols
|
@racket[syntax->datum]:
|
||||||
@racket[foo] and @racket[bar]). Let's use @racket[syntax->datum] to
|
|
||||||
get it:
|
|
||||||
|
|
||||||
@i[
|
@i[
|
||||||
(define-syntax (hyphen-define/ok1 stx)
|
(define-syntax (hyphen-define/ok1 stx)
|
||||||
|
@ -819,7 +816,8 @@ get it:
|
||||||
(syntax-case (datum->syntax stx
|
(syntax-case (datum->syntax stx
|
||||||
(string->symbol (format "~a-~a"
|
(string->symbol (format "~a-~a"
|
||||||
(syntax->datum #'a)
|
(syntax->datum #'a)
|
||||||
(syntax->datum #'b)))) ()
|
(syntax->datum #'b))))
|
||||||
|
()
|
||||||
[name #'(define (name args ...)
|
[name #'(define (name args ...)
|
||||||
body0 body ...)])]))
|
body0 body ...)])]))
|
||||||
(hyphen-define/ok1 foo bar () #t)
|
(hyphen-define/ok1 foo bar () #t)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user