stklos-ref-3.html 22.2 KB
Newer Older
eg's avatar
eg committed
1 2 3
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
Erick's avatar
Erick committed
4
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
eg's avatar
eg committed
5 6 7 8 9 10 11 12 13
 <style type="text/css">
  <!--
  tt { font-family: monospace }
  code { font-family: monospace }
  -->
 </style>
<link href="doc-style.css" rel="stylesheet" type="text/css">
</head>
<body >
Erick's avatar
Erick committed
14 15
<table width='100%' cellpadding='0' cellspacing='0'><tr><td bgcolor="#8A8983"><font color="#FAFAFA"><center><h1>STklos Reference Manual<hr align="center" width="10%">3. Program structure</h1></center></font></table><table cellpadding="3" cellspacing="0" width="100%"><tr>
<td align="left" valign="top" width="20%" bgcolor="#8A8983">
eg's avatar
eg committed
16
<br /><table width="97%" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse;" frame="box" rules="none"><tbody>
Erick's avatar
Erick committed
17
<tr><th align="center" colspan="2" bgcolor="#ACE919"><font color="darkolivegreen">Contents</font></th></tr>
Erick's avatar
Erick committed
18
<tr class="navnorm"><td align="center"></td><td align="left"><a href="stklos-ref.html#-document-44572">*Top*</a></td></tr>
eg's avatar
eg committed
19 20 21 22 23 24 25 26
<tr class="navnorm"><td width="8%" align="left" valign="top">1&nbsp;</td><td align="left"><a href="stklos-ref-1.html#Introduction">Introduction</a></td></tr>
<tr class="navnorm"><td width="8%" align="left" valign="top">2&nbsp;</td><td align="left"><a href="stklos-ref-2.html#Expressions">Expressions</a></td></tr>
<tr class="navsel"><td width="8%" align="left" valign="top">3&nbsp;</td><td align="left"><a href="stklos-ref-3.html#Program-structure">Program structure</a><br /></td></tr>
<tr class="navnorm"><td width="8%" align="left" valign="top">4&nbsp;</td><td align="left"><a href="stklos-ref-4.html#Standard-Procedures">Standard Procedures</a></td></tr>
<tr class="navnorm"><td width="8%" align="left" valign="top">5&nbsp;</td><td align="left"><a href="stklos-ref-5.html#Regular-Expressions">Regular Expressions</a></td></tr>
<tr class="navnorm"><td width="8%" align="left" valign="top">6&nbsp;</td><td align="left"><a href="stklos-ref-6.html#Pattern-Matching">Pattern Matching</a></td></tr>
<tr class="navnorm"><td width="8%" align="left" valign="top">7&nbsp;</td><td align="left"><a href="stklos-ref-7.html#Exceptions-and-Conditions">Exceptions and Conditions</a></td></tr>
<tr class="navnorm"><td width="8%" align="left" valign="top">8&nbsp;</td><td align="left"><a href="stklos-ref-8.html#STklos-Object-System">STklos Object System</a></td></tr>
27 28
<tr class="navnorm"><td width="8%" align="left" valign="top">9&nbsp;</td><td align="left"><a href="stklos-ref-9.html#Threads--Mutexes-and-Condition-Variables">Threads, Mutexes and Condition Variables</a></td></tr>
<tr class="navnorm"><td width="8%" align="left" valign="top">10&nbsp;</td><td align="left"><a href="stklos-ref-10.html#Customizations">Customizations</a></td></tr>
Erick Gallesio's avatar
Erick Gallesio committed
29
<tr class="navnorm"><td width="8%" align="left" valign="top">11&nbsp;</td><td align="left"><a href="stklos-ref-11.html#The-ScmPkg-Package-System">The ScmPkg Package System</a></td></tr>
30 31 32 33 34
<tr class="navnorm"><td width="8%" align="left" valign="top">12&nbsp;</td><td align="left"><a href="stklos-ref-12.html#Foreign-Function-Interface">Foreign Function Interface</a></td></tr>
<tr class="navnorm"><td width="8%" align="left" valign="top">13&nbsp;</td><td align="left"><a href="stklos-ref-13.html#Using-the-SLIB-package">Using the SLIB package</a></td></tr>
<tr class="navnorm"><td width="8%" align="left" valign="top">14&nbsp;</td><td align="left"><a href="stklos-ref-14.html#SRFIs">SRFIs</a></td></tr>
<tr class="navnorm"><td width="8%" align="left" valign="top">15&nbsp;</td><td align="left"><a href="stklos-ref-15.html#Index">Index</a></td></tr>
<tr class="navnorm"><td width="8%" align="left" valign="top">&nbsp;</td><td align="left"><a href="stklos-ref-16.html#Bibliography">Bibliography</a></td></tr>
eg's avatar
eg committed
35 36 37 38 39 40
</tbody></table>
</td>
<td align="left" valign="top">
<p>R5RS discusses how to structure programs. Everything which is defined
in Section 5 of R5RS applies also to STklos. To make things
shorter, this aspects will not be described here (see R5RS for
Erick's avatar
Erick committed
41
complete information).</p><a name="--index-entry-9014"></a><a name="--index-entry-9018"></a><p>STklos modules can be used to organize a program into separate
eg's avatar
eg committed
42 43
environments (or <em>name spaces</em>). Modules provide a clean way to
organize and enforce the barriers between the components of a program.</p><p>STklos provides a simple module system which is largely inspired from
44
the one of Tung and Dybvig exposed in [<a href="stklos-ref-16.html#Tung-Dybvig-96">14</a>]. As their
eg's avatar
eg committed
45
modules system, STklos modules are defined to be easily used in an
Erick's avatar
Erick committed
46 47
interactive environment. </p><a name="--index-entry-9029"></a><a name="--index-entry-9033"></a><br /><table cellspacing="0" cellpadding="0" width="100%"><tbody>
<tr><td bgcolor="#dddddd"><a name="define-module"></a><a name="--index-entry-9039"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
eg's avatar
eg committed
48 49 50 51 52 53 54 55
<tr><td align="left"><code><strong><font color="IndianRed">(define-module &lt;name&gt; &lt;expr1&gt; &lt;expr2&gt; ...)</font></strong></code></td><td align="right"><font color="darkolivegreen"><i><span style="font-variant: small-caps">STklos</span> syntax</i></font></td></tr>
</tbody></table>
<br /><code>Define-module</code> evaluates the expressions <code>&lt;expr1&gt;</code>, <code>&lt;expr2&gt;</code> ... which
constitute the body of the module <code>&lt;name&gt;</code> in the environment of that module.
<code>Name</code> must be a valid symbol. If this symbol has not already been used to
define a module, a new module, named <code>name</code>, is created.
Otherwise, the expressions <code>&lt;expr1&gt;</code>, <code>&lt;expr2&gt;</code> ... are evaluated in
the environment of the (old) module <code>&lt;name&gt;</code>
Erick's avatar
Erick committed
56
<a href="#fn--footnote-9166"><sup><small>1</small></sup></a>.
Erick's avatar
Erick committed
57
Definitions done in a module are local to the module and do not interact with
eg's avatar
eg committed
58 59
the definitions in other modules. Consider the following definitions,
<blockquote><table cellspacing="0" class="code" cellpadding="4" width="90%"><tbody>
Erick's avatar
Erick committed
60
<tr><td bgcolor="ivory"><pre>(<font color="#6959cf"><strong>define-module</strong></font> M1
eg's avatar
eg committed
61 62 63 64 65 66 67 68 69
   (<font color="#6959cf"><strong>define</strong></font> a 1))

(<font color="#6959cf"><strong>define-module</strong></font> M2
  (<font color="#6959cf"><strong>define</strong></font> a 2)
  (<font color="#6959cf"><strong>define</strong></font> b (* 2 x)))
</pre></td></tr>
</tbody></table></blockquote>


Erick's avatar
Erick committed
70
Here, two modules are defined and they both bind the symbol <code>a</code> to a
eg's avatar
eg committed
71
value. However, since <code>a</code> has been defined in two distinct modules
Erick's avatar
Erick committed
72
they denote two different locations.
eg's avatar
eg committed
73 74 75 76 77 78 79 80 81
<br /><br />
The <code><span style="font-variant: small-caps">STklos</span></code> module, which is predefined, is a special module which
contains all the <em>global variables</em> of a <span style="font-variant: small-caps">R<sup>5</sup>RS</span> program.  A symbol
defined in the <code><span style="font-variant: small-caps">STklos</span></code> module, if not hidden by a local definition, is
always visible from inside a module. So, in the previous exemple, the
<code>x</code> symbol refers the <code>x</code> symbol defined in the <code><span style="font-variant: small-caps">STklos</span></code> module.
<br /><br />
The result of <code>define-module</code> is <em>void</em>.</td></tr>
</tbody></table><br /><table cellspacing="0" cellpadding="0" width="100%"><tbody>
Erick's avatar
Erick committed
82
<tr><td bgcolor="#dddddd"><a name="current-module"></a><a name="--index-entry-9202"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
eg's avatar
eg committed
83 84 85 86
<tr><td align="left"><code><strong><font color="IndianRed">(current-module)</font></strong></code></td><td align="right"><font color="darkolivegreen"><i><span style="font-variant: small-caps">STklos</span> procedure</i></font></td></tr>
</tbody></table>
<br />Returns the current module.
<blockquote><table cellspacing="0" class="code" cellpadding="4" width="90%"><tbody>
Erick's avatar
Erick committed
87
<tr><td bgcolor="ivory"><pre>(<font color="#6959cf"><strong>define-module</strong></font> M
Erick's avatar
Erick committed
88
  (display
eg's avatar
eg committed
89 90 91 92 93 94 95
      (cons (eq? (current-module) (find-module 'M))
            (eq? (current-module) (find-module '<span style="font-variant: small-caps">STklos</span>)))))
   -| (#t . #f)
</pre></td></tr>
</tbody></table></blockquote>
</td></tr>
</tbody></table><br /><table cellspacing="0" cellpadding="0" width="100%"><tbody>
Erick's avatar
Erick committed
96
<tr><td bgcolor="#dddddd"><a name="find-module"></a><a name="--index-entry-9243"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
eg's avatar
eg committed
97 98 99 100 101
<tr><td align="left"><code><strong><font color="IndianRed">(find-module name)</font></strong></code></td><td align="right"><font color="darkolivegreen"><i><span style="font-variant: small-caps">STklos</span> procedure</i></font></td></tr>
</tbody></table>
<code><strong><font color="IndianRed">(find-module name default)</font></strong></code><br /><br /><span style="font-variant: small-caps">STklos</span> modules are first class objects and <code>find-module</code> returns the
module associated to <code>name</code> if it exists. If there is no module
associated to <code>name</code>, an error is signaled if no <code>default</code> is
Erick's avatar
Erick committed
102
provided, otherwise <code>find-module</code> returns <code>default</code>.</td></tr>
eg's avatar
eg committed
103
</tbody></table><br /><table cellspacing="0" cellpadding="0" width="100%"><tbody>
Erick's avatar
Erick committed
104
<tr><td bgcolor="#dddddd"><a name="module-"></a><a name="--index-entry-9300"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
eg's avatar
eg committed
105 106 107 108
<tr><td align="left"><code><strong><font color="IndianRed">(module? object)</font></strong></code></td><td align="right"><font color="darkolivegreen"><i><span style="font-variant: small-caps">STklos</span> procedure</i></font></td></tr>
</tbody></table>
<br />Returns <code>#t</code> if <code>object</code> is a module and <code>#f</code> otherwise.
<blockquote><table cellspacing="0" class="code" cellpadding="4" width="90%"><tbody>
Erick's avatar
Erick committed
109
<tr><td bgcolor="ivory"><pre>(module? (find-module 'STklos))  &#8658; #t
eg's avatar
eg committed
110 111 112 113 114 115
(module? 'STklos)                &#8658; #f
(module? 123 'no)                &#8658; no
</pre></td></tr>
</tbody></table></blockquote>
</td></tr>
</tbody></table><br /><table cellspacing="0" cellpadding="0" width="100%"><tbody>
Erick's avatar
Erick committed
116
<tr><td bgcolor="#dddddd"><a name="export"></a><a name="--index-entry-9359"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
eg's avatar
eg committed
117 118
<tr><td align="left"><code><strong><font color="IndianRed">(export &lt;symbol1&gt; &lt;symbol2&gt; ...)</font></strong></code></td><td align="right"><font color="darkolivegreen"><i><span style="font-variant: small-caps">STklos</span> syntax</i></font></td></tr>
</tbody></table>
Erick's avatar
Erick committed
119 120
<br />Specifies the symbols which are exported (i.e. <em>visible</em>) outside
the current module. By default, symbols defined in a module are not
eg's avatar
eg committed
121
visible outside this module, excepted if they appear in an <code>export</code>
Erick's avatar
Erick committed
122
clause.
eg's avatar
eg committed
123 124 125 126 127 128 129
<br /><br />
If several <code>export</code> clauses appear in a module, the set of
exported symbols is determined by ``<em>unionizing</em>'' symbols exported
in all the <code>export</code> clauses.
<br /><br />
The result of <code>export</code> is <em>void</em>.</td></tr>
</tbody></table><br /><table cellspacing="0" cellpadding="0" width="100%"><tbody>
Erick's avatar
Erick committed
130
<tr><td bgcolor="#dddddd"><a name="import"></a><a name="--index-entry-9418"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
eg's avatar
eg committed
131 132 133 134
<tr><td align="left"><code><strong><font color="IndianRed">(import &lt;module1&gt; &lt;module2&gt; ...)</font></strong></code></td><td align="right"><font color="darkolivegreen"><i><span style="font-variant: small-caps">STklos</span> syntax</i></font></td></tr>
</tbody></table>
<br />Specifies the modules which are imported by the current module.
Importing a module makes the symbols it exports visible to the
Erick's avatar
Erick committed
135
importer, if not hidden by local definitions. When a symbol
eg's avatar
eg committed
136 137
is exported by several of the imported modules, the location denoted by
this symbol in the importer module correspond to the one of the first module
Erick's avatar
Erick committed
138
in the list
eg's avatar
eg committed
139
<blockquote><table cellspacing="0" class="code" cellpadding="4" width="90%"><tbody>
Erick's avatar
Erick committed
140
<tr><td bgcolor="ivory"><pre>(<font color="#1919af"><strong>&lt;module1&gt;</strong></font> <font color="#1919af"><strong>&lt;module2&gt;</strong></font> ...)
eg's avatar
eg committed
141 142 143
</pre></td></tr>
</tbody></table></blockquote>

Erick's avatar
Erick committed
144
which exports it.
eg's avatar
eg committed
145 146
<br /><br />
If several <code>import</code> clauses appear in a module, the set of
Erick's avatar
Erick committed
147 148
imported modules  is determined by appending the various list of modules
in their apparition order.
eg's avatar
eg committed
149 150

<blockquote><table cellspacing="0" class="code" cellpadding="4" width="90%"><tbody>
Erick's avatar
Erick committed
151
<tr><td bgcolor="ivory"><pre>(<font color="#6959cf"><strong>define-module</strong></font> M1
eg's avatar
eg committed
152 153 154 155 156
  (<font color="#00cf00">export</font> a b)
  (<font color="#6959cf"><strong>define</strong></font> a 'M1-a)
  (<font color="#6959cf"><strong>define</strong></font> b 'M1-b))

(<font color="#6959cf"><strong>define-module</strong></font> M2
Erick Gallesio's avatar
Erick Gallesio committed
157
  (<font color="#00cf00">export</font> b c d)
eg's avatar
eg committed
158
  (<font color="#6959cf"><strong>define</strong></font> b 'M2-b)
Erick Gallesio's avatar
Erick Gallesio committed
159 160
  (<font color="#6959cf"><strong>define</strong></font> c 'M2-c)
  (<font color="#6959cf"><strong>define</strong></font> d 'M2-d))
eg's avatar
eg committed
161 162 163

(<font color="#6959cf"><strong>define-module</strong></font> M3
  (<font color="#00cf00">import</font> M1 M2)
Erick Gallesio's avatar
Erick Gallesio committed
164
  (display (list a b c d)))  -| (M1-a M1-b M2-c M2-d)
eg's avatar
eg committed
165 166 167 168
</pre></td></tr>
</tbody></table></blockquote>


Erick Gallesio's avatar
Erick Gallesio committed
169 170 171 172
(define-module M4
  (import M2 M1)
  (display (list a b c d)))  -| (M1-a M2-b M2-c M2-d)
</td></tr>
eg's avatar
eg committed
173
</tbody></table><br /><table cellspacing="0" cellpadding="0" width="100%"><tbody>
Erick's avatar
Erick committed
174
<tr><td bgcolor="#dddddd"><a name="select-module"></a><a name="--index-entry-9500"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
eg's avatar
eg committed
175 176
<tr><td align="left"><code><strong><font color="IndianRed">(select-module &lt;name&gt;)</font></strong></code></td><td align="right"><font color="darkolivegreen"><i><span style="font-variant: small-caps">STklos</span> syntax</i></font></td></tr>
</tbody></table>
Erick's avatar
Erick committed
177 178 179
<br />Changes the value of the current module to the module with the given <code>name</code>.
The expressions evaluated after <code>select-module</code> will take place in
module <code>name</code> environment.  Module <code>name</code> must have been created
eg's avatar
eg committed
180 181 182 183 184
previously by a <code>define-module</code>. The result of <code>select-module</code> is
<em>void</em>.
<code>Select-module</code> is particularly useful when debugging since it
allows to place toplevel evaluation in a particular module. The
following transcript shows an usage of <code>select-module</code>.
Erick's avatar
Erick committed
185
<a href="#fn--footnote-9567"><sup><small>2</small></sup></a>:
eg's avatar
eg committed
186
<blockquote><table cellspacing="0" class="code" cellpadding="4" width="90%"><tbody>
Erick's avatar
Erick committed
187
<tr><td bgcolor="ivory"><pre>stklos&gt; (<font color="#6959cf"><strong>define</strong></font> foo 1)
eg's avatar
eg committed
188 189 190 191 192 193 194
stklos&gt; (<font color="#6959cf"><strong>define-module</strong></font> bar
          (<font color="#6959cf"><strong>define</strong></font> foo 2))
stklos&gt; foo
1
stklos&gt; (<font color="#00cf00">select-module</font> bar)
bar&gt; foo
2
Erick's avatar
Erick committed
195 196
bar&gt; (<font color="#00cf00">select-module</font> stklos)
stklos&gt;
eg's avatar
eg committed
197 198 199 200
</pre></td></tr>
</tbody></table></blockquote>
</td></tr>
</tbody></table><br /><table cellspacing="0" cellpadding="0" width="100%"><tbody>
Erick's avatar
Erick committed
201
<tr><td bgcolor="#dddddd"><a name="symbol-value"></a><a name="--index-entry-9590"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
eg's avatar
eg committed
202 203 204
<tr><td align="left"><code><strong><font color="IndianRed">(symbol-value symbol module)</font></strong></code></td><td align="right"><font color="darkolivegreen"><i><span style="font-variant: small-caps">STklos</span> procedure</i></font></td></tr>
</tbody></table>
<code><strong><font color="IndianRed">(symbol-value symbol module default)</font></strong></code><br /><br />Returns the value bound to <code>symbol</code> in <code>module</code>. If <code>symbol</code> is not bound,
Erick's avatar
Erick committed
205
an error is signaled if no <code>default</code> is provided, otherwise <code>symbol-value</code>
eg's avatar
eg committed
206 207
returns <code>default</code>.</td></tr>
</tbody></table><br /><table cellspacing="0" cellpadding="0" width="100%"><tbody>
Erick's avatar
Erick committed
208
<tr><td bgcolor="#dddddd"><a name="symbol-value-"></a><a name="--index-entry-9643"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
eg's avatar
eg committed
209 210 211
<tr><td align="left"><code><strong><font color="IndianRed">(symbol-value* symbol module)</font></strong></code></td><td align="right"><font color="darkolivegreen"><i><span style="font-variant: small-caps">STklos</span> procedure</i></font></td></tr>
</tbody></table>
<code><strong><font color="IndianRed">(symbol-value* symbol module default)</font></strong></code><br /><br />Returns the value bound to <code>symbol</code> in <code>module</code>. If <code>symbol</code> is not bound,
Erick's avatar
Erick committed
212
an error is signaled if no <code>default</code> is provided, otherwise <code>symbol-value</code>
eg's avatar
eg committed
213 214 215 216 217 218
returns <code>default</code>.
<br /><br />
Note that this function searches the value of <code>symbol</code> in <code>module</code>
<strong>and</strong> all the modules it imports whereas <code>symbol-value</code> searches
only in <code>module</code>.</td></tr>
</tbody></table><br /><table cellspacing="0" cellpadding="0" width="100%"><tbody>
Erick's avatar
Erick committed
219
<tr><td bgcolor="#dddddd"><a name="module-name"></a><a name="--index-entry-9724"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
eg's avatar
eg committed
220 221 222 223
<tr><td align="left"><code><strong><font color="IndianRed">(module-name module)</font></strong></code></td><td align="right"><font color="darkolivegreen"><i><span style="font-variant: small-caps">STklos</span> procedure</i></font></td></tr>
</tbody></table>
<br />Returns the name (a symbol) associated to a <code>module</code>.</td></tr>
</tbody></table><br /><table cellspacing="0" cellpadding="0" width="100%"><tbody>
Erick's avatar
Erick committed
224
<tr><td bgcolor="#dddddd"><a name="module-imports"></a><a name="--index-entry-9748"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
eg's avatar
eg committed
225 226
<tr><td align="left"><code><strong><font color="IndianRed">(module-imports module)</font></strong></code></td><td align="right"><font color="darkolivegreen"><i><span style="font-variant: small-caps">STklos</span> procedure</i></font></td></tr>
</tbody></table>
Erick's avatar
Erick committed
227
<br />Returns the list of modules that <code>module</code> (fully) imports.</td></tr>
eg's avatar
eg committed
228
</tbody></table><br /><table cellspacing="0" cellpadding="0" width="100%"><tbody>
Erick's avatar
Erick committed
229
<tr><td bgcolor="#dddddd"><a name="module-exports"></a><a name="--index-entry-9772"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
eg's avatar
eg committed
230 231 232
<tr><td align="left"><code><strong><font color="IndianRed">(module-exports module)</font></strong></code></td><td align="right"><font color="darkolivegreen"><i><span style="font-variant: small-caps">STklos</span> procedure</i></font></td></tr>
</tbody></table>
<br />Returns the list of symbols exported by <code>module</code>. Note that this function
Erick's avatar
Erick committed
233
returns the list of symbols given in the module <code>export</code> clause and that
eg's avatar
eg committed
234 235
some of these symbols can be not yet defined.</td></tr>
</tbody></table><br /><table cellspacing="0" cellpadding="0" width="100%"><tbody>
Erick's avatar
Erick committed
236
<tr><td bgcolor="#dddddd"><a name="module-symbols"></a><a name="--index-entry-9801"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
eg's avatar
eg committed
237 238 239 240
<tr><td align="left"><code><strong><font color="IndianRed">(module-symbols module)</font></strong></code></td><td align="right"><font color="darkolivegreen"><i><span style="font-variant: small-caps">STklos</span> procedure</i></font></td></tr>
</tbody></table>
<br />Returns the list of symbols already defined in <code>module</code>.</td></tr>
</tbody></table><br /><table cellspacing="0" cellpadding="0" width="100%"><tbody>
Erick's avatar
Erick committed
241
<tr><td bgcolor="#dddddd"><a name="all-modules"></a><a name="--index-entry-9825"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
eg's avatar
eg committed
242 243 244 245
<tr><td align="left"><code><strong><font color="IndianRed">(all-modules)</font></strong></code></td><td align="right"><font color="darkolivegreen"><i><span style="font-variant: small-caps">STklos</span> procedure</i></font></td></tr>
</tbody></table>
<br />Returns the list of all the living modules.</td></tr>
</tbody></table><br /><table cellspacing="0" cellpadding="0" width="100%"><tbody>
Erick's avatar
Erick committed
246
<tr><td bgcolor="#dddddd"><a name="in-module"></a><a name="--index-entry-9844"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
eg's avatar
eg committed
247 248 249 250 251 252 253
<tr><td align="left"><code><strong><font color="IndianRed">(in-module mod s)</font></strong></code></td><td align="right"><font color="darkolivegreen"><i><span style="font-variant: small-caps">STklos</span> syntax</i></font></td></tr>
</tbody></table>
<code><strong><font color="IndianRed">(in-module mod s default)</font></strong></code><br /><br />This form returns the value of symbol with name <code>s</code> in the module with name
<code>mod</code>. If this symbol is not bound,  an error is signaled if no <code>default</code> is
provided, otherwise <code>in-module</code> returns <code>default</code>. Note that the value of <code>s</code>
is searched in <code>mod</code> and all the modules it imports.
<br /><br />
Erick's avatar
Erick committed
254
This form is in fact a shortcut. In effect,
eg's avatar
eg committed
255
<blockquote><table cellspacing="0" class="code" cellpadding="4" width="90%"><tbody>
Erick's avatar
Erick committed
256
<tr><td bgcolor="ivory"><pre>(in-module my-module foo)
eg's avatar
eg committed
257 258 259 260 261 262
</pre></td></tr>
</tbody></table></blockquote>

<br /><br />
is equivalent to
<blockquote><table cellspacing="0" class="code" cellpadding="4" width="90%"><tbody>
Erick's avatar
Erick committed
263
<tr><td bgcolor="ivory"><pre>(symbol-value* 'foo (find-module 'my-module))
eg's avatar
eg committed
264 265 266 267
</pre></td></tr>
</tbody></table></blockquote>
</td></tr>
</tbody></table><br><br><hr width='20%' size='2' align='left'>
Erick's avatar
Erick committed
268
<a name="fn--footnote-9166"><sup><small>1</small></sup></a>: In fact <code>define-module</code> on a given name
eg's avatar
eg committed
269
	     defines a new module only the first time it is invoked on this name.
Erick's avatar
Erick committed
270
	     By this way, interactively reloading a module does not define
eg's avatar
eg committed
271 272
	     a new entity, and the other modules which use it are not altered.
<br>
Erick's avatar
Erick committed
273
<a name="fn--footnote-9567"><sup><small>2</small></sup></a>: This transcript uses the default toplevel loop
eg's avatar
eg committed
274 275 276 277 278
	       which displays the name of the current module in the evaluator
	       prompt.
<br>
</td>
</tr></table><small><hr>This <span style="font-variant: small-caps">Html</span> page has been produced by 
Erick's avatar
Erick committed
279
                                     <a href="http://www.stklos.net/~eg/Publis/JFP05/article.html">Skribe</a>.<br />Last update <em>Fri Apr 20 19:24:44 2018</em></small>
eg's avatar
eg committed
280 281
</body>
</html>