amkhlv
amkhlv

Reputation: 337

how to separate define-syntax from syntax-case in Racket

Consider the following two pieces of Racket code:

;version A
(define-syntax (b stx) 
  (syntax-case stx () [(X u) #'(display  (syntax->datum #'(X u v)))]))
(b 1)

and

;version B
(define-for-syntax (g stx) 
  (syntax-case stx () [(X u) #'(display  (syntax->datum #'(X u v)))]))
(define-syntax (b s) (g s))
(b 1)

Experimentally, both programs return (b 1 v). Question: Is "version B" a valid Racket? If so, is it fully equivalent to "version A"?

Upvotes: 3

Views: 204

Answers (1)

Sam Tobin-Hochstadt
Sam Tobin-Hochstadt

Reputation: 5053

Yes, both of these are fine, and do exactly the same thing, as you've noticed.

Upvotes: 4

Related Questions