[r6rs-discuss] [Formal] Rename named `let'

From: Eli Barzilay <eli>
Date: Thu Jan 25 21:28:43 2007

On Jan 25, Michael Sperber wrote:
> The fact that the convenient syntax for writing recursive procedures
> is part of `let' is a long-standing wart in the syntax of Scheme.

I disagree.


> It is unintuitive (it expands into `letrec', rather than a simpler
> form of `let), difficult to explain to newcomers to Scheme, and
> disconcerting to the casual reader.
>
> How to fix:
>
> If the syntax needs to be integrated with one of the standard
> binding forms, it should be `letrec', not `let'. However, it would
> be much better to rename named `let' to something else such as
> `rec', `recur' or `recursive'.

If you view

  (let ([x v] ...) body ...)

as sugar for

  ((lambda (x ...) body ...) v ...)

then a named let makes a lot of sense -- it simply gives a name to
that function. It just happens that this needs a letrec in the
expansion, but it's unrelated to the let bindings (now function
bindings) that are still bound in the same way. An unnamed let can
expand to a similar letrec, except that the name is never used so it
can be skipped.

If you're suggesting:

  (letrec loop ([x ...]) body ...)

then I don't understand how it can work in any intuitive way. Worse,
I find it very common to write

  (define (tree-foo foo tree)
    (let loop ([tree tree])
      ...))

which breaks if it was using a letrec.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!
Received on Thu Jan 25 2007 - 21:28:38 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC