//  SPDX-License-Identifier: GFDL-1.3-or-later
//
//  Copyright © 2000-2023 Erick Gallesio <eg@stklos.net>
//
//           Author: Erick Gallesio [eg@unice.fr]
//    Creation date: 26-Nov-2000 18:19 (eg)

{{chapter "Program structure"}}


((("modules")))
((("libraries")))
((("name space")))
((("global variable")))
((("variable")))

Since its origin, {{stklos}} offers a module system which can be used
to organize a program into separate environments (or *_name
spaces_*). The module system is directly inherited from {{stk}}. This
module system is largely inspired from the one of Tung and
Dybvig exposed in Tung and Dybvig paper <<TuD96>>. As this module
system, {{stk}} and {{stklos}} modules are defined to be easily used
in an interactive environment.

{{stklos}} modules provide a clean way to organize and enforce the
barriers between the components of a program. At this time, the
current version of Scheme was {{rfive}} which didn't define a module
system. However, since then, {{rseven}} has defined the notion of
libraries, which are similar, in the intent, to {{stklos}} modules.
Consequently, {{stklos}} offers both systems: modules and libraries
(the latter being implemented on top of the former).

=== Modules

{{insertdoc 'define-module}}
{{insertdoc 'find-module}}
{{insertdoc 'module?}}
{{insertdoc 'module-name}}
{{insertdoc 'current-module}}
{{insertdoc 'select-module}}

{{insertdoc 'symbol-value}}
{{insertdoc 'symbol-value*}}
{{insertdoc 'symbol-bound?}}
{{insertdoc 'module-symbols}}
{{insertdoc 'module-symbols*}}

{{insertdoc 'export}}
{{insertdoc 'import}}
{{insertdoc 'module-imports}}
{{insertdoc 'module-exports}}
{{insertdoc 'module-immutable!}}
{{insertdoc 'module-mutable?}}
{{insertdoc 'in-module}}
{{insertdoc 'all-modules}}
{{insertdoc 'module-list}}

=== Libraries

The library concept is defined in {{rseven}} ans is supported in {{stklos}}.
As said before, libraries are implemented with modules. Briefly
stated, the library |(lib a b)| will be implemented with a module whose name
is |lib/a/b| and the |STklos| module has been deleted from the import list.

(((export)))
(((import)))
(((begin)))
(((include)))
(((include-ci)))
(((include-library-declarations)))
(((cond-expand)))
{{insertdoc 'define-library}}
{{insertdoc 'library?}}
{{insertdoc 'library-name}}
{{insertdoc 'library-list}}

=== Variables and Constants

{{insertdoc 'define}}
{{insertdoc 'define-constant}}
{{insertdoc 'symbol-immutable!}}
{{insertdoc 'symbol-mutable?}}

