slang-users mailing list

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

Re: [slang-users] Bug in namespace allocation


Hello John,

John E. Davis schrieb am Fri 07. Oct, 11:48 (-0400):
> I am not convinced that it is a problem.  For example, try removing
> the implements line from test1.sl.  You will find it works:
> 
>    $ slsh /tmp/test.sl
>    _test
>    bar

But this leads to very strange errors:

#v+
$ cat /tmp/test.sl 
autoload("foo", "/tmp/test1.sl");
autoload("_test->bar", "/tmp/test1.sl");

define bar()
{
    message("bar not in test1.sl");
}
bar();

foo();
bar();
_test->bar();

message("");
foreach (_get_namespaces())
{
    loop ( _apropos( (), "bar", 0xF) ) {
        "->"; exch();
        () + () + ();
        message( () );
    }
}
$ cat /tmp/test1.sl 
% try whether reevaluation works in SLANG 2
% implements("_test");
message(current_namespace());

public define foo()
{
    message("foo");
}

define bar()
{
    message("bar");
}

$ slsh /tmp/test.sl 
bar not in test1.sl

foo
bar
_test
bar

_test->bar
Global->bar
#v-

Global->bar from test.sl gets overwritten because no namespace is given
to the autoload() for foo. So you can't refer to the public functions in
a unit with autoload(), otherwise other functions in the Global namespace
may become overwritten.

Regards, Jörg.
-- 
Perfection is reached, not when there is no longer anything that can be
added, but when there is no longer anything to take away.
                                        (Antoine de Saint-Exupery)

Attachment: pgpT9nZ7HZZpg.pgp
Description: PGP signature


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