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

From: Paulo J. Matos (pocmatos at gmail.com)
Date: Wed Jun 24 14:02:49 EDT 2009

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



Posted on the users mailing list.