www.delorie.com/gnu/docs/kawa/kawa_69.html   search  
Buy GNU books!

Kawa, the Java-based Scheme system

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.8.1 Name visibility

The definitions that a module exports are accessible to other modules. These are the "public" definitions, to use Java terminology. By default, all the identifiers declared at the top-level of a module are exported, except those defined using define-private. However, a major purpose of using modules is to control the set of names exported. One reason is to reduce the chance of accidental name conflicts between separately developed modules. An even more important reason is to enforce an interface: Client modules should only use the names that are part of a documented interface, and should not use internal implementation procedures (since those may change).

If there is a module-export declaration in the module, then only those names listed in a module-export are exported. There can be more than one module-export, and they can be anywhere in the Scheme file. As a matter of good style, I recommend a single module-export near the beginning of the file.

Syntax: module-export name ...
Make the definition for each name be exported. Note that it is an error if there is no definition for name in the current module, or if it is defined using define-private.

In this module, fact is public and worker is private:
(module-export fact)
(define (worker x) ...)
(define (fact x) ...)

Alternatively, you can write:
(define-private (worker x) ...)
(define (fact x) ...)

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003