This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: nested modules / anonymous modules


Jost Boekemeier <jostobfe@calvados.zrz.TU-Berlin.DE> writes:

> > > (define some-value 1)
> > > (define mod-signature1
> > > 	(module (ice-9 test)
> > > 		(open (ice-9 debug))
> > > 		(export ...)
> > > 		(begin 
> > > 			(define a 12)
> > > 			some-value ; -> error
> > 
> > 			^^^^^^^^^^^^^^^^^^^^^
> > 
> > This semantics breaks lexical scoping and is clearly unacceptable in
> > Scheme.
> 
> 
> Umm.  Why do you think that (eval ...) is not acceptable?
> 
> 
> 
> (module (root)
> 	(begin (define x 12)
> 		(module (sub1))
> 			(begin (define x (+ x 1))
> 			(module ...))))
> 

I don't see how the two examples compare: in the second example,
define introduces a new binding for x, while in the first example, the
old binding would still persist. Besides, if you do think of modules
as Java classes, nesting, in presence of lexical scoping, maps to
inheritance. So in the second example define 'overrides' the root
definition, while in the first example some-value just defaults to
root. Again, that's the way scoping normally works in Scheme.

> >and please explain why it's the same as having no modules at all
> 
> When you open and extend the root module you implicitly open and
> extend *all* modules.

During interaction you'd extend a module that doesn't have to be root
(for example, (ice-9 repl)). In all other cases, well, that behaviour
was obvious consequence of #1 design, now why is that a problem?

-- 
How to eff the ineffable?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]