Examples
Add some example code
This commit is contained in:
parent
f951d6609d
commit
0383c6bc49
21
examples.rkt
Normal file
21
examples.rkt
Normal file
|
@ -0,0 +1,21 @@
|
|||
#lang racket
|
||||
|
||||
(require (for-syntax syntax/parse))
|
||||
|
||||
(require generic-syntax-expanders)
|
||||
|
||||
(define-syntax-with-expanders blah
|
||||
(syntax-parser
|
||||
[(_ (any ...))
|
||||
#'(begin (foo any) ...)]))
|
||||
|
||||
(define-blah-expander baz
|
||||
(syntax-parser
|
||||
[(_ n:number)
|
||||
#`(#,@(build-list (syntax-e #'n) values))]))
|
||||
|
||||
(expand-once #'(blah (1 2 3 4 5)))
|
||||
;; => expands to (begin (foo 1) (foo 2) (foo 3) (foo 4) (foo 5))
|
||||
|
||||
(expand-once #'(blah (baz 5)))
|
||||
;; => expands to (begin (foo 0) (foo 1) (foo 2) (foo 3) (foo 4))
|
Loading…
Reference in New Issue
Block a user