On 6/17/19 4:20 PM, Robert Girault wrote:
I was able to do the first half of exercise 1 (see sources at the end
of this message) --- write a macro computing some information at
run-time. The second half is to write the same macro, but computing
some information at compile-time --- I couldn't do this one. I'm
looking for some directions on how to achieve this.
(*) Context
; Syntax -> Syntax
; (define-world* name ...) defines all name ... to stand for a string
(define-syntax (define-world* stx)
(syntax-parse stx
((_ x:id ...)
#'(define-values (x ...) (values (begin 'x "world") ...)))))
(*) Exercise 1
Exercise 1. Modify define-world* so that it binds each given
identifier to its place in the sequence. We start counting at 0 so
that
(define-world* x y z)
binds x to 0, y to 1, and so on.
Hint 1: If you were going to translate this one example by hand, here's
one way to do it:
(define-values (x y z) (values 0 1 2))
Hint 2: Here's another way to do it:
(begin (define x 0) (define y 1) (define z 2))
Why might the first version be "better" than the second version (from a
macro-writer's point of view, at least)?
Ryan
--
You received this message because you are subscribed to the Google Groups "Racket
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/racket-users/9aa7b28d-97db-43aa-46a4-336683cce65f%40ccs.neu.edu.
For more options, visit https://groups.google.com/d/optout.