Hi--
I am developing a project that is going to use plugins. It's at a very
early stage, and I am not at all sure how the details of the system will
work, but my thinking at this point is that the plugins:
- may be either compiled or interpreted, but will usually be
compiled as shared libraries; and
- will be stored in one or more arbitrary locations separate from
the system's egg repository.
- should ideally be implemented as modules.
So I think what I want to do is to load shared libraries containing
modules into compiled code. Toward that end, I have been experimenting with
some toy code to try to understand the various ways that different
compilation units interact. I have four library units, 'a', 'b', 'c', and
'd', and two top-level units, 'ab' (which uses 'a' and 'b'), and 'cd'
(which uses 'c' and 'd'). The important difference between the libraries is
that 'c' and 'd' declare modules, while 'a' and 'b' do not. Here's the
code:
; a.scm
(define (ay) (print "Ay, what's 'appening?"))
; b.scm
(define (bee) (print "2B or not 2B?"))
; c.scm
(module c
*
(import scheme)
(import chicken)
(define (see) (print "See Spot run."))
)
; d.scm
(module d
*
(import scheme)
(import chicken)
(define (dee) (print "Defenestrate depraved demons."))
)
; ab.scm
(load-relative "a.so")
(load-relative "b.so")
(ay)
(bee)
: cd.scm
(load-relative "c.so")
(load-relative "d.so")
(import c)
(import d)
(see)
(dee)
And here's what happens when I try to work with them:
$ csc -dynamic a.scm
$ csc -dynamic b.scm
$ csc -dynamic c.scm
$ csc -dynamic d.scm
$ csi
CHICKEN
(c)2008-2012 The Chicken Team
(c)2000-2007 Felix L. Winkelmann
Version 4.8.0 (rev 0db1908)
linux-unix-gnu-x86 [ manyargs dload ptables ]
compiled 2012-09-24 on debian (Linux)
... [ loading ~/.csirc and various eggs ] ...
csi> (load "ab.scm")
; loading ab.scm ...
; loading a.so ...
; loading b.so ...
Ay, what's 'appening?
2B or not 2B?
csi> (load "cd.scm")
; loading cd.scm ...
; loading c.so ...
; loading d.so ...
See Spot run.
Defenestrate depraved demons.
csi>
$ csc ab.scm
$ ./ab
Ay, what's 'appening?
2B or not 2B?
$ csc cd.scm
Syntax error (import): cannot import from undefined module
c
By the way, in addition to 'load-relative', I've also tried loading
the libs by means of 'require' (with and without the so-name), 'load',
and 'require-library'. In no case have I managed to compile a unit that
loads a library containing a module.
So, I hope it is reasonably clear what I am trying to do here. Is this
something that is supposed to work? Is there perhaps a compiler
directive that would solve this problem?
--
Matt Gushee
_______________________________________________
Chicken-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-users