summaryrefslogtreecommitdiff
path: root/examples/box-dynamic-module/README
blob: 6e4636fa3c091b4c0acd0668c82689c2660569bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
							       -*- text -*-

This directory includes an example program for extending Guile with a
new (and even useful) data type, putting it into a shared library, so it 
can be called from an unmodified guile interpreter. Further, the shared 
library defines a new guile module.

To build the example, simply type

  make libbox-module

in this directory.

A box is simply an object for storing one other object in.  It can be
used for passing parameters by reference, for example.  You simply
store an object into a box, pass it to another procedure which can
store a new object into it and thus return a value via the box.

Box objects are created with `make-box', set with `box-set!' and
examined with `box-ref'.  Note that these procedures are placed in a
module called (box-module) and can thus only be accessed after using
this module.  See the following example session for usage details:

Extend your LD_LIBRARY_PATH variable (or equivalent) to include . and
.libs and make sure that your current working directory is the one
this file is contained in.

If you like this example so much that you want to have it available
for normal usage, install the dynamic libraries in the .libs directory
to the directory $(prefix)/lib and the scheme file `box-module.scm' in
a directory in your GUILE_LOAD_PATH.

$ guile
guile> (use-modules (box-module))
guile> (define b (make-box))
guile> b
#<box #f>
guile> (box-set! b '(list of values))
guile> b
#<box (list of values)>
guile> (box-ref b)
(list of values)
guile> (quit)
$