slang-users mailing list

[2004 Date Index] [2004 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [slang-users] Re: new slang 2 development snapshot released


Joerg Sommer <joerg@xxxxxxxxxxxx> wrote:
>The problem is caused in line 112 in slimport.c.
>
>   if (NULL != find_handle (name))
>     return 0;			       /* already loaded */
>
>There is a check, if the module is already loaded. This is the case, if
>you have loaded it under the namespace foo. If you define name a little
>bit better, it should work.

The problem is that SLang_Name_Type[1] objects are stored in hash
tables in the form of a linked list.  When loading a module into
another namespace, it is not sufficient to simply reload the module
without performing a copy of the objects that the module adds to the
interpreter.  You can see this for yourself by loading the following
into slsh linked to your patched version of slang.  

define add_names (num, ns)
{
   _for (0, num-1, 1)
     {
	variable x = ();
	eval (sprintf ("static variable x%d=%d;", x, x), ns);
     }
}
add_names (5000, "foo");
vmessage ("foo contains %d symbols", length (_apropos ("foo", ".", 0xF)));
import ("varray", "bar");
vmessage ("bar contains %d symbols", length (_apropos ("bar", ".", 0xF)));
import ("varray", "foo");
vmessage ("foo now contains %d symbols", length (_apropos ("foo", ".", 0xF)));
vmessage ("bar now contains %d symbols", length (_apropos ("bar", ".", 0xF)));

The proper behavior is for bar to contain exactly one symbol
(mmap_array).  You will find that importing varray into foo after it
was imported into bar results in the corruption of bar's namespace.

[1] Note: SLang_Name_Type plays the role of an abstract class for
SLang_Intrin_Fun_Type, SLang_Intrin_Var_Type, etc...

Thanks,
--John

_______________________________________________
To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html


[2004 date index] [2004 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]