Commit | Line | Data |
---|---|---|
673509f8 MG |
1 | -*- outline -*- |
2 | ||
3 | * Overview | |
2de7ddb7 MG |
4 | |
5 | This directory includes an example program for extending Guile with a | |
6 | new (and even useful) data type. | |
7 | ||
673509f8 MG |
8 | |
9 | * Build Instructions | |
10 | ||
2de7ddb7 MG |
11 | To build the example, simply type |
12 | ||
13 | make box | |
14 | ||
15 | in this directory. | |
16 | ||
17 | The resulting `box' program is a Guile interpreter which has one | |
18 | additional data type called `box'. | |
19 | ||
673509f8 MG |
20 | |
21 | * The Box Data Type | |
22 | ||
2de7ddb7 MG |
23 | A box is simply an object for storing one other object in. It can be |
24 | used for passing parameters by reference, for example. You simply | |
25 | store an object into a box, pass it to another procedure which can | |
26 | store a new object into it and thus return a value via the box. | |
27 | ||
673509f8 MG |
28 | |
29 | ** Usage | |
30 | ||
2de7ddb7 MG |
31 | Box objects are created with `make-box', set with `box-set!' and |
32 | examined with `box-ref'. See the following example session for usage | |
33 | details: | |
34 | ||
673509f8 MG |
35 | |
36 | ** Example Session | |
37 | ||
2de7ddb7 MG |
38 | $ ./box |
39 | guile> (define b (make-box)) | |
40 | guile> b | |
41 | #<box #f> | |
42 | guile> (box-set! b '(list of values)) | |
43 | guile> b | |
44 | #<box (list of values)> | |
45 | guile> (box-ref b) | |
46 | (list of values) | |
47 | guile> (quit) | |
48 | $ |