Subject: Re: MACROLET and lexical environment
From: rpw3@rpw3.org (Rob Warnock)
Date: Sun, 04 Jul 2004 20:20:29 -0500
Newsgroups: comp.lang.lisp
Message-ID: <VqWdnQfV5YpAMXXdRVn-uA@speakeasy.net>
Peter Seibel  <peter@javamonkey.com> wrote:
+---------------
| The docs for MACROLET say:
|   The macro-expansion functions defined by macrolet are defined in the
|   lexical environment in which the macrolet form appears. Declarations
|   and macrolet and symbol-macrolet definitions affect the local macro
|   definitions in a macrolet...
...
|   bindings that are visible in that lexical environment.
| 
| So my question is: is the new macro definition supposed to be in the
| environment that is passed to the local macro.
+---------------

I think so. Looking in the "Discussion" section of "Issue
DECLARATION-SCOPE:NO-HOISTING Summary" (which, yes, I know
is not normative), one finds this:

    -- for LABELS and MACROLET, a function name's scope includes all the
       code forms for the functions being defined by the special form
       [a compiler writer must know how not to get into an infinite loop
       of substitutions when there are 'in-line' declarations on these
       mutually recursive names];

+---------------
| In Allegro 6.2 it [his example] appears to go into infinite recursion;
+---------------

In CMUCL as well.

+---------------
| I was sort of hoping for it to find the global definition of FOO,
| i.e. be more like FLET than LABELS.
+---------------

I understand, but the above "Issue" quote suggests the opposite.

Also consider that DEFMACRO definitions are allowed to be self-recursive
(and if so, must be careful to terminate), so it seems reasonable that
MACROLET definitions would also be allowed to be self-recursive.

But that's just IMHO...


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607