README 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. -*- outline -*-
  2. * Overview
  3. This directory includes an example program for extending Guile with a
  4. new (and even useful) data type, putting it into a shared library, so it
  5. can be called from an unmodified guile interpreter.
  6. * Build Instructions
  7. To build the example, simply type
  8. make libbox
  9. in this directory.
  10. * The Box Data Type
  11. A box is simply an object for storing one other object in. It can be
  12. used for passing parameters by reference, for example. You simply
  13. store an object into a box, pass it to another procedure which can
  14. store a new object into it and thus return a value via the box.
  15. ** Usage
  16. Box objects are created with `make-box', set with `box-set!' and
  17. examined with `box-ref'. Note that these procedures are placed in a
  18. module called (box-module) and can thus only be accessed after using
  19. this module. See the following example session for usage details:
  20. Extend your LD_LIBRARY_PATH variable (or equivalent) to include . and
  21. .libs
  22. ** Example Session
  23. $ guile
  24. guile> (load-extension "libbox" "scm_init_box")
  25. guile> (define b (make-box))
  26. guile> b
  27. #<box #f>
  28. guile> (box-set! b '(list of values))
  29. guile> b
  30. #<box (list of values)>
  31. guile> (box-ref b)
  32. (list of values)
  33. guile> (quit)
  34. $
  35. * Module Installation
  36. If you like this example so much that you want to have it available
  37. for normal usage, install the dynamic libraries in the .libs directory
  38. to the directory $(prefix)/lib