[plt-scheme] Undefined identifier? hey... it's defined!
On Wed, 2009-06-24 at 14:13 -0400, Matthias Felleisen wrote:
> 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.
>
>
You're right.. it does make sense... wierd I only stumbled at it now.
I always thought that rhs of definitions were only evaluated in a
sequence outside of a module and inside it wouldn't make sense.
>
>
> 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
>