Re: Expansion problem
Jean-Michel HUFFLEN <jmhuffle-qPpMuP/[email protected]>
| Newsgroups | gmane.comp.lang.racket.user,gmane.lisp.scheme.plt |
|---|---|
| Message-ID | <[email protected]> |
Philip McGrath <philip-HuI0B06iylScIzJqBAPImwC/[email protected]> wrote: > The bindings of a `let`/`let*`/etc. form can be generated by > macro-expansion, but the binding pairs are not expressions: a > transformer/macro binding for the left-hand-side identifier doesn't trigger > macro expansion. This is a good thing, because otherwise you wouldn't be > able to let-bind names defined as macros. OK, I understand, thank you. I think that this feature is not related to racket but should be present in Scheme in general. But that not obvious: if I understood, bindings for let*-like forms cannot be expanded in the sense that (x y) is expanded if x is a macro name. But such expressions can be followed by "...". Finally, I rewrote "do*" as follows: (define-syntax do* (syntax-rules () ((do* ((var init step) ...) (test expr-0 ...) body-expr-0 ...) (let* ((var init) ...) (let loop ((var var) ...) (if test (do* "ending" expr-0 ...) (begin body-expr-0 ... (let* ((var step) ...) (loop var ...))))))) ((do* ((var init step ...) ...) (test expr-0 ...) body-expr-0 ...) (do* ((do* "place-step" var init step ...) ...) (test expr-0 ...) body-expr-0 ...)) ((do* "ending") (if #f #f)) ((do* "ending" expr-0) expr-0) ((do* "ending" expr-0 ...) (begin expr-0 ...)) ((do* "place-step" var init) (var init var)) ((do* "place-step" var init step) (var init step)))) > (...) > - I see that you have `(do* "ending")` expand to `(if #f #f)`, which is > a syntax error in Racket. > - Using strings to dispatch to your additional cases will work, but it > would be most idiomatic to use Racket's keywords Yes, but in fact, I started with defining "do*" in Racket's R7RS mode. Many thanks for you help. J.-M. H. ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. -- 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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] For more options, visit https://groups.google.com/d/optout.