Fix infinite loop in expander
[bpt/guile.git] / examples / box-module / README
CommitLineData
673509f8
MG
1 -*- outline -*-
2
3* Overview
2de7ddb7
MG
4
5This directory includes an example program for extending Guile with a
6new (and even useful) data type.
7
8The `box' program created by this example is nearly identical to the
9one produced in directory ../box, with one (important) difference: The
10interpreter in this directory will place all defined primitive
11procedures in a module called (box-module). That means that this
12module must be used before the primitives can be accessed.
13
673509f8
MG
14
15* Build Instructions
16
2de7ddb7
MG
17To build the example, simply type
18
19 make box
20
21in this directory.
22
23The resulting `box' program is a Guile interpreter which has one
24additional data type called `box'.
25
673509f8
MG
26
27* The Box Data Type
28
2de7ddb7
MG
29A box is simply an object for storing one other object in. It can be
30used for passing parameters by reference, for example. You simply
31store an object into a box, pass it to another procedure which can
32store a new object into it and thus return a value via the box.
33
673509f8
MG
34
35** Usage
36
2de7ddb7
MG
37Box objects are created with `make-box', set with `box-set!' and
38examined with `box-ref'. Note that these procedures are placed in a
39module called (box-module) and can thus only be accessed after using
40this module. See the following example session for usage details:
41
673509f8
MG
42
43** Example Session
44
2de7ddb7
MG
45$ ./box
46guile> (use-modules (box-module))
47guile> (define b (make-box))
48guile> b
49#<box #f>
50guile> (box-set! b '(list of values))
51guile> b
52#<box (list of values)>
53guile> (box-ref b)
54(list of values)
55guile> (quit)
56$