On 6/19/07, Alex Shinn <[EMAIL PROTECTED]> wrote:
On 6/18/07, felix winkelmann <[EMAIL PROTECTED]> wrote: > > Should there be bugs, or if the code generated is too big, compiler macros > (which implement this feature) can be disabled via the > "-disable-compiler-macros" > option to chicken/csc.Nice! I've been wanting compiler macros for a while :) Among other things, they can be used to implement another feature I've wanted, first-class inlined procedures: (define-compiler-macro (define-inline* params . body) (let ((body `(begin ,@body))) `(begin (define ,params ,body) (define-compiler-macro ,params `,,body)))) (define-inline* (foo x) ...) This way FOO is inlined when applied directly, but is still available as a normal procedure for first class usages (e.g. with APPLY) and at runtime.
Careful: compiler macros are run *after* any highlevel macro-expanders have processed the code, so they should expand into code that does not use macros (this doesn't come up with low-level macros, as they are expanded as a toplevel expression is "canonicalized" - first macros are expanded, then compiler macros). But all highlevel macro systems (syntax-case, syntactic-closures, alexpander, rex) must expand toplevel expressions completely and will not run after a compiler macro has been expanded. So compiler macros are not for general use (and so they are undocumented), but are sometimes the only way of getting something to work. cheers, felix _______________________________________________ Chicken-users mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/chicken-users
