Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Library loading

4 views
Skip to first unread message

Dan Sugalski

unread,
Apr 28, 2004, 11:17:28 AM4/28/04
to perl6-i...@perl.org
Okay, here's the scoop, since nobody worked out anything much better.

The interpreter has a library array. We can stick it somewhere in the
interpreter structure and hang it off the interpinfo op to get to it.

Each element in the array is a sub PMC. The prototype is:

int loader(string)

The return is:

1 - no good, try the next entry in the array
0 - Good, done
-1 - good, try the next entry in the array anyway
exception - something went wrong

The string parameter is the unqualified name of the library to load.
The parameter is explicitly writable so filter entries can mess with
it if they want.

If the last entry in the array returns non-zero, then a library load
fail exception is thrown.

This does mean that each plain directory in the library path has to
have what's essentially a closure backing it which is capable of
loading in a file from disk into the interpreter, but I'm OK with
that. It'll make wedging in more active library loading code easier
in general, which is fine.
--
Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk

Jens Rieks

unread,
Apr 28, 2004, 12:38:08 PM4/28/04
to perl6-i...@perl.org, Dan Sugalski
On Wednesday 28 April 2004 17:17, Dan Sugalski wrote:
>    1 - no good, try the next entry in the array
>    0 - Good, done
>    -1 - good, try the next entry in the array anyway
>    exception - something went wrong
>
> The string parameter is the unqualified name of the library to load.
> The parameter is explicitly writable so filter entries can mess with
> it if they want.
Then another code should be added to indicate that the library name has been
rewritten and that search should be restarted..?
In what case will a handler return -1?

jens

Dan Sugalski

unread,
Apr 28, 2004, 12:43:41 PM4/28/04
to Jens Rieks, perl6-i...@perl.org

The handler returns -1 in those cases where it's rewritten the
library name. It'll also return that in the case where it may have
done something successful (such as log the load request) but wants
the load to continue anyway.

Arguably no loader in the list ever has to return a -1 result, as
they could still do their thing and return a 1, but I figured it'd be
useful to have a way for loaders to indicate they did something but
that the search wasn't over.

0 new messages