[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Semantics of let



>>>>> haahr@mv.us.adobe.com (Paul Haahr) writes:

[about letting let act like let, not let*]

Paul> what do other people on this list think?

I think it's the Right Thing to do, provided of course it can be
implemented cleanly.

Paul> re letrec:  currently the only way to create recursive structures
Paul> is to use assignment or something like the y combinator. [...]

I don't think I quite understand.  The only recursiveness you create
using letrec is indirect, in the sense that a program fragment would
not contain a copy of itself, but has to dereference a variable to
refer to itself.  In fact, you can get the effect of
    letrec (a=foo; b=bar) {cmd}
by rewriting it as
    let (a=; b=) {a=foo; b=bar; cmd}
which certainly causes no problem.  Of course, this means that letrec
can simply be implemented as syntactic sugar, just like let* can, given
the "real" let.

Heck, even let can be written as syntactic sugar in terms of lambda!
You just have to use some program fragments to get around the fact
that es doesn't have hierarchical lists:

; x=foo zoo; y=bar zar
; # Think if this as a rewrite of  let (x=$y; y=$x) echo $x $y
; @ x y {x=<=$x; y=<=$y; echo $x $y} {result $y} {result $x}
bar zar foo zoo

- Harald