README 1.4 KB

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