[plt-scheme] to define, or to let

From: Bradd W. Szonye (bradd+plt at szonye.com)
Date: Sun Mar 21 00:57:34 EST 2004

Felix Klock's PLT scheme proxy wrote:
> May I propose the following compromise:

Sure, that's reasonable.

> The MzScheme extension to the semantics of LETREC is technically legal
> according to R5RS; therefore Eli is completely justified in writing
> such expressions when programming for PLT Scheme (after all, he has
> stated that he deliberately chooses not to target all R5RS-Scheme's,
> but rather just PLT Scheme).

Please note that part of it may be "technically illegal." IIRC, PLT
Scheme does not implement the requirement to assign all of the variables
*after* evaluating the right-hand sides.

It could meet that requirement and still permit the extension it does
now. However, it would need to bind/assign the variables at least twice:
Once during evaluation, and once after evaluation.

Note that this requirement is not very important; several other Scheme
implementations violate it, and it's difficult to imagine a program that
would depend on the specified behavior.

> Therefore, the extension should remain as 100% legal code for the PLT
> family of languages in DrScheme (Textual, Graphical, Pretty Big, etc).

I agree, with some reservations. I'm opposed to guaranteed evaluation
order for let and letrec in general, but it's documented behavior that
some users rely on, so it would be bad to change it.

> However, for the Standard (R5RS) language, DrScheme should (at least)
> print a warning for such uses of LETREC.

That would be excellent, but it might be difficult or expensive to
detect. I suspect that R5RS makes it a no-diagnostic-required error for
a reason.

It's pretty easy to detect at run time if you use a straightforward
implementation that binds all the variables to "bad" values, evaluates
the RHSes, and then SET!s the variables. It's harder to detect at
compile time, and it may be impossible to detect if you try to provide
the diagnostic *and* the current behavior.

> This way, a developer who wants to focus on targeting the R5RS family
> can be more confident that they are not relying on this (and other)
> PLT Scheme extensions to the standard.

That's an excellent idea, and it's a good way to eliminate "quiet"
extensions, when you can detect them. Unfortunately, detection may be
difficult in this case. (I haven't looked at it closely enough to judge
with confidence, so take my opinion here with a grain of salt.)

> So, we have a Feature Request (or Bug Report) for the R5RS language, 
> but otherwise we have nothing left to discuss.
> How does that sound?

Sounds good (with the reservations noted above).

> ----
> I think scheme would get a lot more mindshare if they'd
> change the keyword "lambda" to "lambada"

Bradd W. Szonye

Posted on the users mailing list.