| www.delorie.com/gnu/docs/guile/guile_17.html | search |
![]() Buy GNU books! | |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Of course it is possible to write modules yourself. Using modules for structuring your programs makes them more readable and lets you distribute them more easily. Also, explicitly defining the procedures and variables which are exported from a module adds documentation to the source and specifies the interface a module provides.
In Guile, you can create new modules and switch to existing modules in
order to add bindings to them using the syntactic form
define-module.
(define-module (foo bar)) (define (frob x) x) |
Will create the module (foo bar).(1) All definitions following this statement will add bindings
to the module (foo bar), and these bindings will not be visible
outside of the module. To make the bindings accessible to other
modules, you have to export them explicitly using one of the following
means:
export form:
(export frob) |
define-module form with the keyword
export:
(define-module (foo bar) #:export (frob)) |
frob to use define-public, which
is a combination of define and export.
(define-public (frob x) x) |
After exporting, other modules can access the exported items simply by
using use-modules to load the module (foo bar).
| webmaster donations bookstore | delorie software privacy |
| Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |