- Subject: Re: [slang-users] Re: slang2 pre-release snapshot 4 available
- From: "John E. Davis" <davis@xxxxxxxxxxxxx>
- Date: Tue, 22 Feb 2005 11:01:48 -0500
Joerg Sommer <joerg@xxxxxxxxxxxx> wrote:
>BTW: John, did implement the possibility to mark a whole namespace for
> autoload? I don't find how to do that?
I have not implemented that. I still remain unconvinced about its
practical benefits.
>BTW2: Where should appear the implements()? I place it as the first
> statement in a file like package in java or namespace in C++. But if
> loading the file fails, because of a syntax error, I can't reload this
> file, because the namespace exists.
It depends. Consider
implements ("foo");
define bar () {...}
This will place bar in the foo namespace. However,
define bar () {...}
implements ("foo");
Here, bar will be placed in the public namespace. If you want to to
go into the foo namespace, then use:
static define bar () {...}
implements ("foo");
Note also that you can use multiple namespaces in a file. For example:
implements ("foo1");
define bar () {message ("foo1");}
implements ("foo2");
define bar () {message ("foo2");}
implements ("foo3");
define bar () {message ("foo3");}
implements ("foo4");
define bar () {message ("foo4");}
foo1->bar();
foo2->bar();
foo3->bar();
foo4->bar();
I personally feel that "implements" should be used rarely. Consider
this:
slsh> !cat /tmp/test.sl
static variable X = current_namespace ();
define bar ()
{
message ("namesapce=$X"$);
}
slsh> ()=evalfile("/tmp/test.sl", "foo");
slsh> foo->bar;
namesapce=foo
slsh> autoload("goo->bar", "/tmp/test.sl");
slsh> goo->bar();
namesapce=goo
As you can see, I did not use implements but nevertheless managed to
create namespaces.
I hope this adds some light on the subject.
Thanks,
--John
_______________________________________________
To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html
[2005 date index]
[2005 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]