> On Mar 11, 2019, at 11:21 AM, Brian Adkins <lojicdot...@gmail.com> wrote:
> 
> I just discovered that define will fail at runtime, where let would fail at 
> compile time. Besides helping to keep the indentation level from marching to 
> the right "too much", what are the benefits of define over let?
> 
> --- snip ---
> #lang racket
> 
> (define (f n) (+ n 1))
> 
> (define (foo)
>   (define b (f a))
>   (define a 7)
>   
>   b)
> 
> (define (bar)
>   (let ([b (f a)]
>         [a 7])
> 
>     b))
> --- snip ---



I think your characterization is a bit misleading here. 

In ‘bar’ ‘a’ is not bound, something that Racket (and DrRacket) properly signal 
at compile time. 

In ‘foo’ ‘a’ *is* bound, because you’ve set up a mutually recursive scope. But, 
when Racket evaluates (foo) it notices that ‘a’ is bound but uninitialized, 
which is two different things. 

If you want to compare apples to apples, use a ‘letrec' instead of a ‘let' in 
‘bar'. Then you have (1) the same semantics and (2) the same error. 

— Matthias

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to