1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-03 05:20:16 +02:00
guile/examples/box-module
Martin Grabmüller 211e9d8a0d * box-module/Makefile.am (TESTS): New variable.
Create `box' on `make all'.

	* box-module/check.test, box-dynamic-module/check.test,
	* box-dynamic/check.test: New files.

	* box-dynamic/Makefile.am (libbox): Create box library on `make
	all'.
	(TESTS): New variable.

	* box/Makefile.am (TESTS): New variable.
	Create `box' program on `make all', use freshly built Guile for
	building.

	* box/check.test: New file.

	* modules/check.test, safe/check.test, scripts/check.test: Set
	GUILE_LOAD_PATH to make the tests run without installed Guile.
2001-07-17 17:12:33 +00:00
..
.cvsignore * .cvsignore: here and in all subdirectories listing Makefile and 2001-06-02 04:58:55 +00:00
box.c * box-dynamic/README: Corrected sample session. 2001-07-09 19:14:01 +00:00
check.test * box-module/Makefile.am (TESTS): New variable. 2001-07-17 17:12:33 +00:00
Makefile.am * box-module/Makefile.am (TESTS): New variable. 2001-07-17 17:12:33 +00:00
README * scripts/README, scripts/hello.scm, safe/untrusted.scm, 2001-06-14 20:36:06 +00:00

							       -*- outline -*-

* Overview

This directory includes an example program for extending Guile with a
new (and even useful) data type.

The `box' program created by this example is nearly identical to the
one produced in directory ../box, with one (important) difference: The
interpreter in this directory will place all defined primitive
procedures in a module called (box-module).  That means that this
module must be used before the primitives can be accessed.


* Build Instructions

To build the example, simply type

  make box

in this directory.

The resulting `box' program is a Guile interpreter which has one
additional data type called `box'.


* The Box Data Type

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.


** Usage

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:


** Example Session

$ ./box
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)
$