Oh, and note that I changed define-dsl-syntax to _not_ use
define-syntax-rule. That's important, if you're going to use the value of
variables used in macro expansion. The define-syntax-rule form protects
its output; you can't disassemble it and then run parts of the result. You
can print them,
You can do it like this:
https://gist.github.com/carl-eastlund/8640925
Basically, you quasiquote the result of the expansion, and then you unquote
variables when you hit them so that they are evaluated normally. Anything
with an unbound variable will fail at expansion time.
Carl Eastlund
On
Sorry, I was combining all the examples into one for brevity. x has 2
possible bindings (one in the module and one in the macro), y is bound in
the module and closes over the macro, and z is unbound and therefore should
result in an error since nothing can be done with it.
;; example 1 (as per ou
Scott -- I don't understand exactly what you're asking, at least not based
on the example you wrote. You defined x and y, but the error is about z.
Is this just a typo? Or are you expecting a value for z to come from
somewhere?
Carl Eastlund
On Sun, Jan 26, 2014 at 1:01 PM, Scott Klarenbach wr
Thanks a lot Carl...this is very enlightening. If I could impose one last
question before I go off and digest everything:
What is the "correct" approach to capturing the runtime values of any
references that may be bound by the enclosing environment, for splicing
into the final recursively-expand
Scott,
I see what you're doing now. You're not actually trying to use macro
expansion at all; you're just using local-expand to substitute the
definition of pred? where it occurs, so that you can make its macro
definition also serve as its DSL definition. That's sensible, but
local-expand is sti
Just an update, I was able to make this work.
#lang racket
(require (for-syntax racket/syntax syntax/stx))
(define-syntax-rule (pred? x) (> 3 x))
(define-for-syntax (recursive-expand stx)
(let loop ([l (syntax->list stx)])
(cond [(stx-null? l) l]
[(stx-pair? (stx-car l))
(cons (loop (stx-
Carl,
Don't panic :).
I'm not trying to reuse the expanded syntax at runtime. I'm just trying to
parse it out for my own purposes in the context of a dsl that I fully
control. I'm happy to strip all context and just have a list of symbols if
need-be. My problem is much simpler, in that I wish
Scott,
What you're doing isn't possible -- isn't even meaningful -- in general.
You want to expand (MACRO-NAME (pred-a? z) (pred-b? z)) into (MACRO-NAME
(equal? z "hey") (equal? z "there")) for some arbitrary MACRO-NAME you
haven't listed. That's not at all safe! For instance, you did it with th
9 matches
Mail list logo