- Subject: Re: [slang-users] autoload loads two times
- From: "John E. Davis" <davis@xxxxxxxxxxxxx>
- Date: Wed, 26 Jul 2006 12:33:04 -0400
Jörg Sommer <joerg@xxxxxxxxxxxx> wrote:
>==> /tmp/bug.sl <==
>implements("bug");
>autoload("enable_stack_check", "stkcheck");
Since "bug" is the active namespace, stkcheck will be loaded into the
"bug" namespace.
>try
>{
> enable_stack_check();
>}
>catch OpenError: {}
The above will cause stkcheck to load.
>() = evalfile("/tmp/bug2.sl");
This will cause bug2.sl to load. Since no namespace argument was
specified, an anonymous one will be used with public symbols going
into the global namespace.
>==> /tmp/bug2.sl <==
>autoload("enable_stack_check", "stkcheck");
Since an anonymous namespace is active in this context, stkcheck will
get loaded into its own anonymous namespace when enable_stack_check is
called.
>try
>{
> enable_stack_check();
>}
>catch OpenError: {}
The above will trigger stkcheck.sl to get loaded.
>==> /tmp/bug3.sl <==
>implements("bug");
>autoload("Global->enable_stack_check", "stkcheck");
This will cause stkcheck.sl to get loaded using the global namespace
for public objects.
>try
>{
> enable_stack_check();
>}
>catch OpenError: {}
This will cause stkcheck.sl to load with enable_stack_check placed
into the global namespace.
>() = evalfile("/tmp/bug2.sl");
Since enable_stack_check is defined in the global namespace when
bug2.sl is loaded, its autoload statement placing it there will have
no effect.
>% xjed -batch -l /tmp/bug.sl | tail -n5
>loading /usr/share/jed/lib/compress.slc
>loading /tmp/bug.sl
>loading /usr/share/slsh/stkcheck.sl
>loading /tmp/bug2.sl
>loading /usr/share/slsh/stkcheck.sl
The above is exactly what I expected to see.
>% xjed -batch -l /tmp/bug3.sl | tail -n5
>loading /usr/share/jed/lib/modeinfo.slc
>loading /usr/share/jed/lib/compress.slc
>loading /tmp/bug3.sl
>loading /usr/share/slsh/stkcheck.sl
>loading /tmp/bug2.sl
The single load of stkcheck.sl is also correct.
>If I put the autoload() before the implements in bug.sl stkcheck.sl is
>not loaded twice. If I use evalfile() in bug.sl instead of autoload(),
>stkcheck.sl is also loaded only one time. I think this is a bug. autoload
>should behave like evalfile() in this case.
Please re-read the docs for autoload and evalfile. If something is
not clear in the documentation, let me know and I will attempt to
improve it.
Thanks,
--John
_______________________________________________
To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html
[2006 date index]
[2006 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]