Thu Mar 13 12:27:21 EDT 2008
defining names from macro
(define-syntax (foo stx)
#`(define bar 123))
(define-syntax (broem stx)
(syntax-case stx ()
(printf "expanding (broem)\n")
#`(define name 123))))
this defines 'lalala' as a symbol, but 'bar' is not accessible. looks
like a hygiene issue where hygiene has to be broken explicitly?
a better approach is maybe to expand to a 'module' form, so all
symbols are introduces in the same place, and no capturing is
(module state-snarfs "snarfer-lang.ss"
(snarf-from "../base/base.ss" (state) (base) lift-state))
where 'snarf-from' is a macro provided by snarfer-lang.ss which
expands to a #%plain-module-begin form.
rationale: what is a module? it is a finite map (name -> stx/value)
in that sense, a snarf is maybe indeed better exposed as a module
transformer, mapping modules -> module instead of modules -> expressions
again: the alternatives are:
* variable capture for define forms (non-hygienic)
* whole module expression generation