[PRL] scope of top-level defines

Dave Herman dherman at ccs.neu.edu
Mon Apr 4 01:14:06 EDT 2005


I notice that in PLT Scheme, a forward reference in a LETREC that is not 
under a LAMBDA results in an #<undefined> value, whereas a forward 
reference in a DEFINE at the top-level of a module that is not under a 
LAMBDA results in an error:

     (letrec ([x y] [y x]) x) => #<undefined>

     (define x y)
     (define y x)
     => error: reference to an identifier before its definition: y

How do you describe the scoping semantics for the latter behavior? It 
isn't simply that top-level names aren't allowed to be bound to 
#<undefined> values, because I can say:

     (define undefined (letrec ([x y] [y x]) x))

Do you just essentially specify that forward references must be under a 
LAMBDA (or a macro invocation that expands to a LAMBDA etc etc)?

Thanks,
Dave



More information about the PRL mailing list