| 1 |
-*- outline -*- |
| 2 |
|
| 3 |
* Overview |
| 4 |
|
| 5 |
This directory includes an example program for extending Guile with a |
| 6 |
new (and even useful) data type. |
| 7 |
|
| 8 |
|
| 9 |
* Build Instructions |
| 10 |
|
| 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 |
|
| 20 |
|
| 21 |
* The Box Data Type |
| 22 |
|
| 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 |
|
| 28 |
|
| 29 |
** Usage |
| 30 |
|
| 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 |
|
| 35 |
|
| 36 |
** Example Session |
| 37 |
|
| 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 |
$ |