[PRL] scope of top-level defines
Eli Barzilay
eli at barzilay.org
Mon Apr 4 02:47:41 EDT 2005
On Apr 4, Dave Herman wrote:
> I notice that in PLT Scheme, a forward reference in a LETREC that is
> not under a LAMBDA results in an #<undefined> value, whereas a
> forward reference in a DEFINE at the top-level of a module that is
> not under a LAMBDA results in an error:
> [...]
FWIW, MzScheme used to have a `letrec*' form, so `letrec' was
supposedly (I don't remember ever trying it) throwing an error, making
it mimic the toplevel behavior. Obviously, if your Scheme has a
`letrec*' that exposes some `undefined' value which is what your
`letrec' is checking then the whole thing is pointless...
> How do you describe the scoping semantics for the latter behavior?
1. You wave your hands. A lot.
2. You get tired of that, end sink into infinite threads on c.l.s.
3. You get tired of that too, and just use whatever you have, or
become holy and write portable Scheme.
(This is, obviously, my subjective view. YMMV^2.)
BTW, in Cornell, I've went throught some meditation which Greg
Morrisett triggered, trying to come up with substitution rules for the
top-level behavior. His solution involved some fixpoint-like tricks,
which sort of worked for the 5% (the same 5% who would eventually get
the Y combinator thing). My solution for 660 is that you evaluate the
RHS, and "mark yourself that you *know* the value of foo". Crappy,
but works with a broader audience, IME. (And Greg's later solution
was to switch to SML... (Not because of this.))
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://www.barzilay.org/ Maze is Life!
More information about the PRL
mailing list