On Mon, Aug 25, 2008 at 09:47:18AM -0300, Mario Domenech Goulart wrote: > Hi folks. > > Is it possible with chicken 4 to generate toplevel (or module-level) > definitions from a macro (explicit renaming)? > > I mean, I'd like something like: > > (module gen-things * > > (define-syntax gen-thing > (lambda (thing) > `(define ,thing (lambda () (display "hello"))))) > > (gen-thing one-thing) > ) > > So I could use `one-thing' from module `gen-things'.
I think all you need to do is change the macro a bit (untested):
(define-syntax gen-thing
(lambda (exp r cmp)
(let ((thing (cadr exp)))
`(,(r 'define) ,thing (,(r 'lambda) () (,(r 'display) "hello"))))))
Cheers,
Peter
--
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
is especially attractive, not only because it can be economically
and scientifically rewarding, but also because it can be an aesthetic
experience much like composing poetry or music."
-- Donald Knuth
pgpgJhM3Ae8hs.pgp
Description: PGP signature
_______________________________________________ Chicken-users mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/chicken-users
