[plt-scheme] Comments on an alternate syntax for let?
On 07/04/2008, Majorinc, Kazimir <kazimir at chem.pmf.hr> wrote:
> What is the the advantage of
>
> (let ((x 0)(y 1)(z 2)) ...)
>
> over
>
> (let ()
> (define x 0)
> (define y 1)
> (define z 2)
> ...)
>
> except that simultaneus evaluation in the first case? What we can not do
> with second and we can with first?
The second is equivalent to a letrec. The first example which pops to mind is
>
(let ((x 1)
(y 6))
(let ((x (add1 x))
(y (sub1 y)))
(+ x y)))
7
>
(let ()
(define x 1)
(define y 6)
(let ()
(define x (add1 x))
(define y (sub1 y))
(+ x y)))
add1: expects argument of type <number>; given #<undefined>
Henk Boom