[plt-scheme] top-level bindings vs. module imports

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Jun 17 03:44:39 EDT 2004

At Tue, 15 Jun 2004 14:59:15 -0400, Doug Orleans wrote:
> This seems odd to me:
> > (define (car) (car))
> > (car)
> car: expects 1 argument, given 0
> I would expect it to loop.  I think I know what's going on: the
> identifier `car' is module-imported, so it gets expanded to itself
> instead of to `(#%top . car)' in the new procedure body.  Is this a
> bug?

No, it's the intended behavior. The evaluation of `define' affects a
namespace, but its compilation does not.

At Tue, 15 Jun 2004 18:16:28 -0400, Doug Orleans wrote:
> I forgot to mention, I'm using a language that re-exports bindings
> from mzscheme.  This doesn't happen if you start in mzscheme.  Here's
> a full transcript:
>   Welcome to MzScheme version 207.1, Copyright (c) 2004 PLT Scheme, Inc.
>   > (define (car) car)
>   > (eq? car (car))
>   #t
>   > (module foo mzscheme (provide (all-from mzscheme)))
>   > (require foo)
>   > (define (cdr) cdr)
>   > (eq? cdr (cdr))
>   #f

The initial MzScheme namespace is initialized with
`namespace-require/copy', which creates a new top-level `car' (binding
its to the value of `mzscheme''s `car') instead of directly importing
`car' from `mzscheme'.


Posted on the users mailing list.