From: Alan Ruttenberg
Subject: scope question
Date: 
Message-ID: <ALANR.91Jun14122852@chopin.media-lab.media.mit.edu>
I have a question about the interaction of flet and macrolet.

(defun foo () ''outside)
(flet ((foo () ''inside)) (macrolet ((bar () (foo))) (bar)))

Should this return a) 'outside b) 'inside c) signal an error

I've convinced myself that it shouldn't return 'inside. Reasoning:
Flet binds, at run time, the local function foo. Macrolet is expanded
at compile time, so the function is not yet available. If one writes instead
(flet ((foo () ''inside)) (macrolet ((bar () '(foo))) (bar))), then it makes 
sense to return 'inside.

But I'm not sure about whether it should return 'outside. I vote yes, and
a friend votes no.

-alan
From: Tim Moore
Subject: Re: scope question
Date: 
Message-ID: <1991Jun14.104748.9982@hellgate.utah.edu>
In article <···················@chopin.media-lab.media.mit.edu> ·····@chopin.media-lab.media.mit.edu (Alan Ruttenberg) writes:
>
>I have a question about the interaction of flet and macrolet.
>
>(defun foo () ''outside)
>(flet ((foo () ''inside)) (macrolet ((bar () (foo))) (bar)))
>
>Should this return a) 'outside b) 'inside c) signal an error
>
>I've convinced myself that it shouldn't return 'inside. Reasoning:
>Flet binds, at run time, the local function foo. Macrolet is expanded
>at compile time, so the function is not yet available. If one writes instead
>(flet ((foo () ''inside)) (macrolet ((bar () '(foo))) (bar))), then it makes 
>sense to return 'inside.

It depends. In Lisps based on the original CLtL, local macro functions
are defined in the global environment. The local binding of foo isn't
visible, so the form returns OUTSIDE.

However, X3J13 changed the definition of macrolet so that macro
functions are defined "in the lexical environment in which the
MACROLET form appears.." (pg 153, CLtL2). Refering to a local variable
or function binding is "undefined". The above form might return INSIDE
in some interpreters, OUTSIDE in others, or it might signal an error.
Compiling this form will probably signal an error.



-- 
Tim Moore                    ·····@cs.utah.edu {bellcore,hplabs}!utah-cs!moore
"Ah, youth. Ah, statute of limitations."
		-John Waters