|
From: | Matt Gushee |
Subject: | Re: [Chicken-users] Some questions about loading libraries |
Date: | Thu, 17 Jan 2013 15:44:42 -0700 |
> I am developing a project which I expect will involve a number of extensionSure. What does "plugin" mean, though? A dynamically loadable library?
> 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.
I assume it is compiled code? Written in Scheme?
> 1) Is there a way to set an arbitrary search path, such that REQUIRE (orYou could implement your own routine (probably based on "load"), which
> LOAD, or some such thing) will work when the library is in a non-standard
> location?
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 environmentYou can compute arbitrary file-paths and pass them to "load". To make
> 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?
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?
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 thatIt means that if loading is chained, nested "load-relative" calls with
> 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.
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.
[Prev in Thread] | Current Thread | [Next in Thread] |