[plt-scheme] module question

From: Danny Yoo (dyoo at hkn.eecs.berkeley.edu)
Date: Mon May 29 11:04:12 EDT 2006


On Mon, 29 May 2006, jos.koot at tiscali.nl wrote:
> (module a mzscheme
>    (provide a)
>    (define-syntax a (syntax-rules () ((a) 'a))))

Hi Jos,

A major idea behind a module is that, internally, the only initial 
bindings in the module are those defined in the language.  In 'a', the 
module starts off with the 'mzscheme' language primitives, and the rest of 
the module defines an 'a' syntax.


> (require a)

Ok, that's done at toplevel.


> (module b mzscheme
>    (provide b)
>    (define-syntax b (syntax-rules () ((b) (a)))))

But the same rules about modules apply here.  A module acts as an 
isolating container: within the module body, nothing gets in except stuff 
that we require or define.  Since we have no explicit require to module 
'a', the 'a' syntax is unknown in module 'b', even though the 'a' syntax 
is available at toplevel.


Best of wishes!


Posted on the users mailing list.