• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

READMEH A D16-Jul-20181.4 KiB5738

box.cH A D02-Aug-20194.8 KiB16263

README

1							       -*- outline -*-
2
3* Overview
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
14
15* Build Instructions
16
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
26
27* The Box Data Type
28
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
34
35** Usage
36
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
42
43** Example Session
44
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$
57