guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: macros, procedure->macro


From: Neil Jerram
Subject: Re: macros, procedure->macro
Date: 15 Jul 2002 23:42:09 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

>>>>> "Dirk" == Dirk Herrmann <address@hidden> writes:

    Dirk> To clarify I would like to re-state my answer to a previous mail to 
you:

Thanks - the following is exactly what I've been looking for.  (I'm
pretty sure that I have not previously received any such email,
though.)

    Dirk> Macro expansion is neither performed like reading, nor like 
evaluation.
    Dirk> Macro expansion is blocked by quoting _and_ macro definitions.  It is 
not
    Dirk> blocked by lambda or other special forms.  Since macro expansion is
    Dirk> blocked by macro definitions, recursive macro definitions are 
possible.

This sounds good.  But, given that the code for a macro definition
gets wrapped in a lambda, perhaps it would be simpler to say that all
lambdas block macroexpansion, and that macroexpansion of the code
inside the lambda happens when the lambda is first used.  This seems
well defined and easy to understand to me.

    Dirk> Given this, it should be clear why
    Dirk>   (define (foo) (bar))
    Dirk>   (define-macro (bar) #f)
    Dirk>   (foo)
    Dirk> will not work:  The first line is expanded at once.  In contrast,
    Dirk>   (define-macro (foo x) `(list ,(bar x) ,x))
    Dirk>   (define-macro (bar x) `(* ,x ,x))
    Dirk> will work, because the macro definition will not be expanded.

If we follow the all lambdas idea, then the `define' example would
work as well.  Is there any reason why this would be a _bad_ thing?

    Dirk> However, it may be that different macro implementations with different
    Dirk> behaviours can co-exist.  For example, I don't see why you shouldn't 
be
    Dirk> able to mix calls to procedure->memoizing-macro with calls to
    Dirk> define-macro.  Then, for each of the different macro systems the 
behaviour
    Dirk> would have to be defined separately.  Not all possible systems will 
comply
    Dirk> with the demand for a system that supports compilation and efficient
    Dirk> execution, though.

In general, yes.  I don't understand your specific example, though, as
define-macro is implemented using procedure->memoizing-macro, so they
are the same implementation.

        Neil




reply via email to

[Prev in Thread] Current Thread [Next in Thread]