[plt-scheme] Undefined identifier? hey... it's defined!

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Wed Jun 24 14:13:29 EDT 2009

The rhs of definitions are evaluated in sequence. In foo2, you are  
evaluating (bar) in a context where foo1 is bound and evaluated and  
bar isn't. Nothing new.

Then again, in a module this kind of thing could go away.




On Jun 24, 2009, at 2:02 PM, Paulo J. Matos wrote:

> Hi all,
>
> When you think scheme hold no more strange surprises, you end up  
> finding
> something you can't explain. It's even worse when you understand the
> error message but you have no idea why it's being thrown at you.
>
> So this is just small example showing the problem:
> #lang scheme
>
> (define (foo1 x)
>   (let ([y (bar x)])
>     (+ y x)))
>
> (define foo2
>   (let ([y (bar)])
>     (lambda (x)
>       (+ y x))))
>
> (define (bar (x 2))
>   (* x x))
>
> I get in 4.2:
> reference to an identifier before its definition: bar
>
> Why is bar undefined in foo2?
>
> Cheers,
>
> Paulo Matos
>
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.