[plt-scheme] to define, or to let

From: Bradd W. Szonye (bradd+plt at szonye.com)
Date: Sat Mar 20 23:36:42 EST 2004

Richard Cleis wrote:
>> I am not complaining about letrec, I was just responding.  I use let*
>> for this sort of thing anyway, and now I know why.  Is that
>> dangerous?

Eli Barzilay wrote:
> No.  But using letrec is not dangerous too.

Relying on evaluation order in letrec most certainly is dangerous. R5RS
even goes out of its way to warn users that they must not do it! You're
giving very bad advice here. At best -- if you're sure that your current
compiler supports it -- it's a bad habit.

> It would be stylistically bad, but not dangerous since it is
> documented & intentional.

"Documented & intentional" is not incompatible with "dangerous." Lots of
C's misfeatures are documented and intentional. Would you claim that
they aren't dangerous?

> It is true that MzScheme might change tomorrow and throw an error in
> those cases because someone achieved (a new) enlightening, but the
> same argument holds for dropping any MzScheme development tomorrow,
> and switching to MzPerl.

C'mon, this is a ridiculous argument. If you care about portability or
good programming habits at all, it's horribly risky to rely on quiet
extensions like letrec.

> BTW, this dependency *is* useful in cases where you want to write one
> big function that encapsulates lots of smaller definitions:
> 
>   (define (foo ...)
>     (define a ...)
>     (define (bar x) ...)
>     (define b (bar a))
>     ...)
> 
> I believe that trying to make local environments be a little more like
> the global environment is the main reason for this extension.

And I believe that imitating the top level is exactly the wrong thing to
do. It's well-known that the top level is an ugly bunch of hacks
designed to make REPLs easier to use. Again, you're giving horrible
advice.
-- 
Bradd W. Szonye
http://www.szonye.com/bradd


Posted on the users mailing list.