This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


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

Re: Referring variable from one module to an other


Emmanuel Castro <castro@lirmm.fr> writes:

> Consider the two files:
> ;; fileone.scm
> (define alpha 'a)
> ;; end of fileone.scm
> 
> ;; filetwo.scm
> (require <fileone>)      ;; NOTE: fileone.scm must have been compiled
> previously !!!!
> (define (x) (list alpha))
> ;; end of filetwo.scm

I just checked in the following patch, which should fix the problem.

However (more embarassment), you still have alpha being visible
in the current environment after the (require <filetwo>); this is of
course wrong.  The correct behavior happens when you add a type
declaration, for example:
        (define alpha :: <object> 'a)
but if you leave out a type specifier, then a Binding is created and
entered in the global environment.

I have to think about the correct way to handle this bug.

Index: gnu/expr/ModuleExp.java
===================================================================
RCS file: /cvs/kawa/kawa/gnu/expr/ModuleExp.java,v
retrieving revision 1.12
diff -u -r1.12 ModuleExp.java
--- ModuleExp.java	2000/06/11 01:59:20	1.12
+++ ModuleExp.java	2000/10/03 06:44:30
@@ -68,7 +68,7 @@
     for (Declaration decl = firstDecl();
          decl != null;  decl = decl.nextDecl())
       {
-	if (decl.isSimple() && ! decl.isPublic())
+	if ((decl.isSimple() && ! decl.isPublic()) || decl.field != null)
 	  continue;
 	if (decl instanceof kawa.lang.Macro
 	    && ((kawa.lang.Macro) decl).expander instanceof LambdaExp
Index: kawa/standard/require.java
===================================================================
RCS file: /cvs/kawa/kawa/kawa/standard/require.java,v
retrieving revision 1.5
diff -u -r1.5 require.java
--- require.java	2000/06/11 02:11:03	1.5
+++ require.java	2000/10/03 06:44:30
@@ -147,7 +147,10 @@
 		    String fdname
 		      = (fvalue instanceof Named ? ((Named) fvalue).getName()
 			 : fname.intern());
-		    Declaration fdecl = new Declaration(fdname, fld.getType());
+                    Type ftype = fld.getType();
+		    Declaration fdecl = new Declaration(fdname, ftype);
+                    if (ftype.isSubtype(Compilation.typeBinding))
+                      fdecl.setIndirectBinding(true);
 		    if (! isStatic)
 		      fdecl.base = decl;
 		    fdecl.field = fld;

-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/~per/

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