[gambit-list] Is there a way to return "nothing"?

Christian Jaeger christian at pflanze.mine.nu
Tue May 1 05:32:22 EDT 2007


Adrien Pierard wrote:
> The aim is to embed code as a macro in another file, and with the right
> parser, to be able to fetch back this data (no, it's not steganography,
> just Scheme code annotation in Scheme)
> Roughly speaking, I want to write comments in scheme (that would be
> parsed by the REPL, and stripped by the macro)
>   

Maybe I didn't read your mail closely enough. Seems like you might want
to strip sexprs from parts where Scheme doesn't expect code, so even
turning them into (begin) wouldn't work.

If that's the case, there are one or two other things you could do:

- maybe just make the whole form a macro then remove the comment stuff?
(e.g. wrap define and lambda in a macro to remove annotations on
function arguments; I admit that I've been looking for nice ways to
extend define and lambda syntax in an extendable way since I've started
using Scheme, so that e.g. two libraries could both add their own set of
extensions; probably staging would be the right thing (alternatively
emulate staging through some kind of module parametrization of the first
stage library and renaming the macros of the second stage on import to
achieve the same thing over intermediate distinct names). (Does some
macro system already support staging? Do you even know what I'm talking
about?.)

- you could write your own code expander; Gambit has hooks for this.
I've done this for using "namespacing" prefixes to generate SXML
templates, so that e.g.

(define (doc firstname)
(html:html
(html:body
(html:p (string-append "Hello " firstname))))

would be expanded to

(define (doc firstname)
`(html
(body
(p ,(string-append "Hello " firstname))))

(it's in my also-to-be-released cj-sxmltemplates module).

Christian.




More information about the Gambit-list mailing list