[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Chicken 4: how to generate toplevel definitions?
From: |
Peter Bex |
Subject: |
Re: [Chicken-users] Chicken 4: how to generate toplevel definitions? |
Date: |
Mon, 25 Aug 2008 14:55:16 +0200 |
User-agent: |
Mutt/1.4.2.3i |
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
pgpXWSA640g3V.pgp
Description: PGP signature