chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Some questions about loading libraries


From: Felix
Subject: Re: [Chicken-users] Some questions about loading libraries
Date: Tue, 15 Jan 2013 20:42:59 +0100 (CET)

> I am developing a project which I expect will involve a number of extension
> libraries, or plugins (a large number, many of them provided by third
> parties, if my project ever becomes popular). For several reasons (which I
> will explain on request if anyone is curious), I feel it is best *not* to
> implement these libraries as eggs. So I am trying to work out a reasonable
> method for deploying the libraries and loading them at runtime.

Sure. What does "plugin" mean, though? A dynamically loadable library?
I assume it is compiled code? Written in Scheme?

> 1) Is there a way to set an arbitrary search path, such that REQUIRE (or
> LOAD, or some such thing) will work when the library is in a non-standard
> location?

You could implement your own routine (probably based on "load"), which
scans a number of directories. "repository-path" is for eggs, and "require"
respects it. You can also add directories to "##sys#include-pathnames".
I think "require" will try this too.

> 
> 2) Is it possible to load a library selected at runtime (via an environment
> variable, config file, command-line argument ... the exact method isn't
> that important) AND have the symbols defined in that library included in a
> module?

You can compute arbitrary file-paths and pass them to "load". To make
the symbols available, you have to make sure the import-libraries for
the modules are available. How do you use the symbols in the
libraries?  Do you evaluate code at runtime?

> 
> 3) Is there a way for a Chicken executable or library to determine its own
> location in the filesystem?

Hm. You can copy the "C_path_to_executable(argv[ 0 ])" in "chicken.h",
and use it via the foreign-function interface" to get the pathname
of an executable. 

> 
> 4) Is LOAD-RELATIVE broken? I wrote some test code to try to use that
> procedure, but as far as I can tell it behaves just like LOAD, i.e. any
> relative path I give it is determined relative to the current directory
> from which the program is invoked. Though I would note that the
> documentation isn't entirely clear to me: "loads FILE relative to the path
> of the currently loaded file." ...? What does "the currently loaded file"
> mean? I will be happy to post my code if this is not a known issue.

It means that if loading is chained, nested "load-relative" calls with
load files relative to the outer "load"/"load-relative" invocations. e.g.

file a.scm:

...
(load "foo/b.scm")
...

file foo/b.scm:

...
(load-relative "c.scm")         ; <- will load "foo/c.scm"
...

Perhaps, if you describe the implementation of your plugins and the
way the code therein is invoked, we can give more detailed advice.


cheers,
felix



reply via email to

[Prev in Thread] Current Thread [Next in Thread]