Sophie

Sophie

distrib > Fedora > 13 > i386 > media > os > by-pkgid > 52a37fb77746ef557a2ec666070d732e > files > 44

bigloo-doc-3.2b-3.fc12.i686.rpm

<!-- 95% W3C COMPLIANT, 95% CSS FREE, RAW HTML -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title>BiglooA ``practical Scheme compiler''User manual for version 3.2bJune 2009</title>
 <style type="text/css">
  <!--
  pre { font-family: monospace }
  tt { font-family: monospace }
  code { font-family: monospace }
  p.flushright { text-align: right }
  p.flushleft { text-align: left }
  span.sc { font-variant: small-caps }
  span.sf { font-family: sans-serif }
  span.skribetitle { font-family: sans-serif; font-weight: bolder; font-size: x-large; }
  span.refscreen { }
  span.refprint { display: none; }
  -->
 </style>
</head>

<body class="chapter" bgcolor="#ffffff">
<table width="100%" class="skribetitle" cellspacing="0" cellpadding="0"><tbody>
<tr><td align="center" bgcolor="#8381de"><div class="skribetitle"><strong><big><big><big>4. Bigloo<br/>A ``practical Scheme compiler''<br/>User manual for version 3.2b<br/>June 2009 -- Core Language</big></big></big></strong></div><center>
</center>
</td></tr></tbody></table>
<table cellpadding="3" cellspacing="0" width="100%" class="skribe-margins"><tr>
<td align="left" valign="top" class="skribe-left-margin" width="20%" bgcolor="#dedeff"><div class="skribe-left-margin">
<br/><center id='center26310'
><table width="97%" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse;" frame="box" rules="none"><tbody>
<tr bgcolor="#8381de"><th id="tc26300" align="center" colspan="1"><font color="#ffffff"><strong id='bold26298'
>main page</strong></font></th></tr>
<tr bgcolor="#ffffff"><td id="tc26307" align="center" colspan="1"><table width="100%" border="0" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc26303" align="left" valign="top" colspan="1"><strong id='bold26302'
>top:</strong></td><td id="tc26304" align="right" valign="top" colspan="1"><a href="bigloo.html#Bigloo-A-``practical-Scheme-compiler''-User-manual-for-version-3.2b-June-2009" class="inbound">Bigloo<br/>A ``practical Scheme compiler''<br/>User manual for version 3.2b<br/>June 2009</a></td></tr>
</tbody></table>
</td></tr>
</tbody></table>
</center>
<br/><br/><center id='center26320'
><table width="97%" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse;" frame="box" rules="none"><tbody>
<tr bgcolor="#8381de"><th id="tc26314" align="center" colspan="1"><font color="#ffffff"><strong id='bold26312'
>Core Language</strong></font></th></tr>
<tr bgcolor="#ffffff"><td id="tc26317" align="center" colspan="1"><table cellspacing="1" cellpadding="1" width="100%" class="toc">
<tbody>
 <tr><td valign="top" align="left">4.1</td><td colspan="4" width="100%"><a href="bigloo-5.html#Syntax">Syntax</a></td></tr>
 <tr><td></td><td valign="top" align="left">4.1.1</td><td colspan="3" width="100%"><a href="bigloo-5.html#Comments">Comments</a></td></tr>
 <tr><td></td><td valign="top" align="left">4.1.2</td><td colspan="3" width="100%"><a href="bigloo-5.html#Expressions">Expressions</a></td></tr>
 <tr><td></td><td valign="top" align="left">4.1.3</td><td colspan="3" width="100%"><a href="bigloo-5.html#Definitions">Definitions</a></td></tr>
</tbody>
</table>
</td></tr>
</tbody></table>
</center>
<br/><br/><center id='center26330'
><table width="97%" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse;" frame="box" rules="none"><tbody>
<tr bgcolor="#8381de"><th id="tc26324" align="center" colspan="1"><font color="#ffffff"><strong id='bold26322'
>Chapters</strong></font></th></tr>
<tr bgcolor="#ffffff"><td id="tc26327" align="center" colspan="1"><table cellspacing="1" cellpadding="1" width="100%" class="toc">
<tbody>
 <tr><td valign="top" align="left"></td><td colspan="4" width="100%"><a href="bigloo-1.html#Acknowledgements">Acknowledgements</a></td></tr>
 <tr><td valign="top" align="left">1</td><td colspan="4" width="100%"><a href="bigloo-2.html#Table-of-contents">Table of contents</a></td></tr>
 <tr><td valign="top" align="left">2</td><td colspan="4" width="100%"><a href="bigloo-3.html#Overview-of-Bigloo">Overview of Bigloo</a></td></tr>
 <tr><td valign="top" align="left">3</td><td colspan="4" width="100%"><a href="bigloo-4.html#Modules">Modules</a></td></tr>
 <tr><td valign="top" align="left">4</td><td colspan="4" width="100%"><a href="bigloo-5.html#Core-Language">Core Language</a></td></tr>
 <tr><td valign="top" align="left">5</td><td colspan="4" width="100%"><a href="bigloo-6.html#DSSSL-support">DSSSL support</a></td></tr>
 <tr><td valign="top" align="left">6</td><td colspan="4" width="100%"><a href="bigloo-7.html#Standard-Library">Standard Library</a></td></tr>
 <tr><td valign="top" align="left">7</td><td colspan="4" width="100%"><a href="bigloo-8.html#Pattern-Matching">Pattern Matching</a></td></tr>
 <tr><td valign="top" align="left">8</td><td colspan="4" width="100%"><a href="bigloo-9.html#Fast-search">Fast search</a></td></tr>
 <tr><td valign="top" align="left">9</td><td colspan="4" width="100%"><a href="bigloo-10.html#Structures-and-Records">Structures and Records</a></td></tr>
 <tr><td valign="top" align="left">10</td><td colspan="4" width="100%"><a href="bigloo-11.html#Object-System">Object System</a></td></tr>
 <tr><td valign="top" align="left">11</td><td colspan="4" width="100%"><a href="bigloo-12.html#Regular-parsing">Regular parsing</a></td></tr>
 <tr><td valign="top" align="left">12</td><td colspan="4" width="100%"><a href="bigloo-13.html#Lalr(1)-parsing">Lalr(1) parsing</a></td></tr>
 <tr><td valign="top" align="left">13</td><td colspan="4" width="100%"><a href="bigloo-14.html#Posix-Regular-Expressions">Posix Regular Expressions</a></td></tr>
 <tr><td valign="top" align="left">14</td><td colspan="4" width="100%"><a href="bigloo-15.html#Command-Line-Parsing">Command Line Parsing</a></td></tr>
 <tr><td valign="top" align="left">15</td><td colspan="4" width="100%"><a href="bigloo-16.html#Cryptography">Cryptography</a></td></tr>
 <tr><td valign="top" align="left">16</td><td colspan="4" width="100%"><a href="bigloo-17.html#Errors-Assertions-and-Traces">Errors, Assertions, and Traces</a></td></tr>
 <tr><td valign="top" align="left">17</td><td colspan="4" width="100%"><a href="bigloo-18.html#Threads">Threads</a></td></tr>
 <tr><td valign="top" align="left">18</td><td colspan="4" width="100%"><a href="bigloo-19.html#Database-library">Database library</a></td></tr>
 <tr><td valign="top" align="left">19</td><td colspan="4" width="100%"><a href="bigloo-20.html#Multimedia-library">Multimedia library</a></td></tr>
 <tr><td valign="top" align="left">20</td><td colspan="4" width="100%"><a href="bigloo-21.html#Mail-library">Mail library</a></td></tr>
 <tr><td valign="top" align="left">21</td><td colspan="4" width="100%"><a href="bigloo-22.html#Eval-and-code-interpretation">Eval and code interpretation</a></td></tr>
 <tr><td valign="top" align="left">22</td><td colspan="4" width="100%"><a href="bigloo-23.html#Macro-expansion">Macro expansion</a></td></tr>
 <tr><td valign="top" align="left">23</td><td colspan="4" width="100%"><a href="bigloo-24.html#Parameters">Parameters</a></td></tr>
 <tr><td valign="top" align="left">24</td><td colspan="4" width="100%"><a href="bigloo-25.html#Explicit-typing">Explicit typing</a></td></tr>
 <tr><td valign="top" align="left">25</td><td colspan="4" width="100%"><a href="bigloo-26.html#The-C-interface">The C interface</a></td></tr>
 <tr><td valign="top" align="left">26</td><td colspan="4" width="100%"><a href="bigloo-27.html#The-Java-interface">The Java interface</a></td></tr>
 <tr><td valign="top" align="left">27</td><td colspan="4" width="100%"><a href="bigloo-28.html#Bigloo-Libraries">Bigloo Libraries</a></td></tr>
 <tr><td valign="top" align="left">28</td><td colspan="4" width="100%"><a href="bigloo-29.html#Extending-the-Runtime-System">Extending the Runtime System</a></td></tr>
 <tr><td valign="top" align="left">29</td><td colspan="4" width="100%"><a href="bigloo-30.html#SRFIs">SRFIs</a></td></tr>
 <tr><td valign="top" align="left">30</td><td colspan="4" width="100%"><a href="bigloo-31.html#Compiler-description">Compiler description</a></td></tr>
 <tr><td valign="top" align="left">31</td><td colspan="4" width="100%"><a href="bigloo-32.html#User-Extensions">User Extensions</a></td></tr>
 <tr><td valign="top" align="left">32</td><td colspan="4" width="100%"><a href="bigloo-33.html#Bigloo-Development-Environment">Bigloo Development Environment</a></td></tr>
 <tr><td valign="top" align="left">33</td><td colspan="4" width="100%"><a href="bigloo-34.html#Global-Index">Global Index</a></td></tr>
 <tr><td valign="top" align="left">34</td><td colspan="4" width="100%"><a href="bigloo-35.html#Library-Index">Library Index</a></td></tr>
 <tr><td valign="top" align="left"></td><td colspan="4" width="100%"><a href="bigloo-36.html#Bibliography">Bibliography</a></td></tr>
</tbody>
</table>
</td></tr>
</tbody></table>
</center>
</div></td>
<td align="left" valign="top" class="skribe-body"><div class="skribe-body">
<a name="Core-Language" class="mark"></a>
This chapter presents the Bigloo basics. It presents the elements
that compose the body of a module (see <a href="bigloo-4.html#Modules" class="inbound">Modules</a>).<br/><br/>
<!-- Syntax -->
<a name="Syntax"></a>
<div class="section-atitle"><table width="100%"><tr><td bgcolor="#dedeff"><h3><font color="black">4.1 Syntax</font>
</h3></td></tr></table>
</div><div class="section">
<a name="Syntax" class="mark"></a><a name="g1925" class="mark"></a>
The syntax of Bigloo is that of Scheme (a parenthesis based one) with two
exceptions: type information and multi-line comments. Type information is 
supplied when identifiers are introduced (via <code id='code1927'
>lambda</code>, <code id='code1928'
>let</code>, 
<code id='code1929'
>define</code>, ...) and those identifiers holding type information are 
referred to as typed identifiers.<br/><br/><a name="g1931" class="mark"></a>They are defined by the following grammar:<br/><br/><center id='center1936'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ccccff"><pre class="prog" id='prog1934'
>&lt;ident&gt;        ==&gt; &lt;r5rs-ident&gt; | &lt;typed-ident&gt;
&lt;typed-ident&gt;  ==&gt; &lt;r5rs-ident&gt;::&lt;r5rs-ident&gt;
&lt;r5rs-ident&gt;   ==&gt; the standard Scheme identifiers
</pre>
</td></tr>
</tbody></table></center>

For details of the standard Scheme identifiers, see 
info-file `r5rs.info', .<br/><br/><a name="g1938" class="mark"></a><a name="g1940" class="mark"></a><a name="g1942" class="mark"></a><a name="g1944" class="mark"></a>
Multi-lines comments (see <a href="http://srfi.schemers.org/srfi-30/">http://srfi.schemers.org/srfi-30/</a>) 
are defined as:<br/><br/><center id='center1949'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ccccff"><pre class="prog" id='prog1947'
>&lt;ident&gt;        ==&gt; &lt;r5rs-ident&gt; | &lt;typed-ident&gt;
&lt;comment&gt;      ==&gt; ;&lt;all subsequent characters up to a line break&gt;
       	       | #| &lt;comment-text&gt; (&lt;comment&gt; &lt;comment-text&gt;)* |#
&lt;comment-text&gt; ==&gt; &lt;character sequence not containing #| or |#&gt;
</pre>
</td></tr>
</tbody></table></center>

<!-- Comments -->
<a name="Comments"></a>
<div class="subsection-atitle"><table width="100%"><tr><td bgcolor="#ffffff"><h3><font color="#8381de">4.1.1 Comments</font>
</h3></td></tr></table>
</div><div class="subsection">
<a name="Comments" class="mark"></a><a name="g1950" class="mark"></a><a name="g1952" class="mark"></a>
Comments and whitespaces are the same as in 
<a href="./r5rs-5.html#Whitespace and comments">r5rs, Whitespace and comments</a>.<br/><br/><center id='center1960'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog1958'
><font color="#ffa600"><em id='it26331'
>;;; The FACT procedure computes the factorial</em></font>
<font color="#ffa600"><em id='it26333'
>;;; of a non-negative integer.</em></font>
(<font color="#6959cf"><strong id='bold26335'
>define</strong></font> <font color="#6959cf"><strong id='bold26337'
>fact</strong></font>
  (<strong id='bold26339'
>lambda</strong> (n)
    (<strong id='bold26340'
>if</strong> (= n 0)
        1        <font color="#ffa600"><em id='it26341'
>;; Base case: return 1</em></font>
        (* n (fact (- n 1))))))
</pre>
</td></tr>
</tbody></table></center>

In addition, Bigloo supports <em id='emph1961'
>s-expressions</em> comments. These
are introduced with the <code id='code1962'
>#;</code> syntax:<br/><br/><center id='center1969'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog1967'
><font color="#ffa600"><em id='it26343'
>;;; The FACT procedure computes the factorial</em></font>
<font color="#ffa600"><em id='it26345'
>;;; of a non-negative integer.</em></font>
(<font color="#6959cf"><strong id='bold26347'
>define</strong></font> <font color="#6959cf"><strong id='bold26349'
>fact</strong></font>
  (<strong id='bold26351'
>lambda</strong> (n)
    #;(if (&lt; n 2) 1 (* #;n (fact (- n 1))))
    (<strong id='bold26352'
>if</strong> (= n 0)
        1
        (* n (fact (- n 1))))))
</pre>
</td></tr>
</tbody></table></center>
<br/><br/></div>
<!-- Expressions -->
<a name="Expressions"></a>
<div class="subsection-atitle"><table width="100%"><tr><td bgcolor="#ffffff"><h3><font color="#8381de">4.1.2 Expressions</font>
</h3></td></tr></table>
</div><div class="subsection">
<a name="Expressions" class="mark"></a><a name="g1971" class="mark"></a>
Bigloo expressions are the same as in <a href="./r5rs-7.html#Expressions">r5rs, Expressions</a>.
Bigloo has more syntactic keywords than Scheme. The Bigloo syntactic
keywords are:<br/><br/><center id='center1976'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ccccff"><pre class="prog" id='prog1974'
>=&gt;                      do                    or
and                     else                  quasiquote
begin                   if                    quote
case                    lambda                set!
cond                    let                   unquote
unquote-splicing        define                let*
delay                   letrec                module
labels                  try                   define-struct
unwind-protect          bind-exit             define-inline
regular-grammar         lalr-grammar          regular-search
define-expander         define-macro          match-case
match-lambda            pragma                failure
assert                  define-generic        define-method
instantiate             duplicate             with-access
widen!                  shrink!               multiple-value-bind
let-syntax              letrec-syntax         define-syntax
cond-expand             receive               args-parse
define-record-type      and-let*
</pre>
</td></tr>
</tbody></table></center>

All other non atomic Bigloo forms are evaluated as functioncalls or macro class.<br/><br/><table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody>
<tr><td><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc1979" align="left" colspan="1"><em id='it1978'
>&lt;variable&gt;</em></td><td id="tc1980" align="right" colspan="1">syntax</td></tr>
</tbody></table>
<a name="g1984" class="mark"></a><a name="quote" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc1988" align="left" colspan="1"><strong id='bold1986'
>quote</strong><em id='it1987'
> datum</em></td><td id="tc1989" align="right" colspan="1">syntax</td></tr>
</tbody></table>
<table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc1994" align="left" colspan="1"><em id='it1993'
><code id='code1992'
>'</code>datum</em></td><td id="tc1995" align="right" colspan="1">syntax</td></tr>
</tbody></table>
<table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc1999" align="left" colspan="1"><em id='it1998'
>&lt;constant&gt;</em></td><td id="tc2000" align="right" colspan="1">syntax</td></tr>
</tbody></table>
<center id='center2014'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog2012'
>(<font color="#6959cf"><strong id='bold26353'
>define</strong></font> <font color="#6959cf"><strong id='bold26355'
>x</strong></font> 28)                          =&gt;
x                                      =&gt; 28
(<strong id='bold26357'
>quote</strong> a)                              =&gt; A
(<strong id='bold26358'
>quote</strong> #(a b c))                       =&gt; #(A B C)
(<strong id='bold26359'
>quote</strong> (+ 1 2))                        =&gt; (+ 1 2)
'a                                     =&gt; A
'#(a b c)                              =&gt; #(A B C)
'()                                    =&gt; ()
'(+ 1 2)                               =&gt; (+ 1 2)
'(<strong id='bold26360'
>quote</strong> a)                             =&gt; (QUOTE A)
'<font color="red">&quot;abc&quot;</font>                                 =&gt; <font color="red">&quot;abc&quot;</font>
<font color="red">&quot;abc&quot;</font>                                  =&gt; <font color="red">&quot;abc&quot;</font>
'145932                                =&gt; 145932
145932                                 =&gt; 145932
'#t                                    =&gt; #t
#t                                     =&gt; #t
</pre>
</td></tr>
</tbody></table></center>
</td></tr>
</tbody></table><br/>
<table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody>
<tr><td><a name="g2018" class="mark"></a><a name="operator" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc2022" align="left" colspan="1"><strong id='bold2020'
>operator</strong><em id='it2021'
> operand ...</em></td><td id="tc2023" align="right" colspan="1">syntax</td></tr>
</tbody></table>
<a name="g2027" class="mark"></a><a name="g2030" class="mark"></a><center id='center2036'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog2034'
>(+ 3 4)                                =&gt; 7
((<strong id='bold26365'
>if</strong> #f + *) 3 4)                      =&gt; 12
((<strong id='bold26366'
>lambda</strong> (x) (+ 1 x)) 5)               =&gt; 6
</pre>
</td></tr>
</tbody></table></center>
</td></tr>
</tbody></table><br/>
<table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody>
<tr><td><a name="g2040" class="mark"></a><a name="lambda" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc2044" align="left" colspan="1"><strong id='bold2042'
>lambda</strong><em id='it2043'
>  formals body</em></td><td id="tc2045" align="right" colspan="1">syntax</td></tr>
</tbody></table>
<center id='center2063'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog2061'
>(<strong id='bold26367'
>lambda</strong> (x) (+ x x))                   =&gt; <em id='emph2048'
>a procedure</em>
((<strong id='bold26368'
>lambda</strong> (x) (+ x x)) 4)               =&gt; 8<br/><br/>(<font color="#6959cf"><strong id='bold26369'
>define</strong></font> <font color="#6959cf"><strong id='bold26371'
>reverse-subtract</strong></font>
  (<strong id='bold26373'
>lambda</strong> (x y) (- y x)))
(reverse-subtract 7 10)                =&gt; 3<br/><br/>(<font color="#6959cf"><strong id='bold26374'
>define</strong></font> <font color="#6959cf"><strong id='bold26376'
>add4</strong></font>
  (<strong id='bold26378'
>let</strong> ((x 4))
    (<strong id='bold26379'
>lambda</strong> (y) (+ x y))))
(add4 6)                               =&gt; 10<br/><br/>((<strong id='bold26380'
>lambda</strong> x x) 3 4 5 6)                 =&gt; (3 4 5 6)
((<strong id='bold26381'
>lambda</strong> (x y . z) z)
 3 4 5 6)                              =&gt; (5 6)
</pre>
</td></tr>
</tbody></table></center>
</td></tr>
</tbody></table><br/>
<table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody>
<tr><td><a name="g2067" class="mark"></a><a name="if" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc2071" align="left" colspan="1"><strong id='bold2069'
>if</strong><em id='it2070'
> test consequent [alternate]</em></td><td id="tc2072" align="right" colspan="1">syntax</td></tr>
</tbody></table>
<center id='center2080'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog2078'
>(<strong id='bold26382'
>if</strong> (&gt; 3 2) 'yes 'no)                  =&gt; yes
(<strong id='bold26383'
>if</strong> (&gt; 2 3) 'yes 'no)                  =&gt; no
(<strong id='bold26384'
>if</strong> (&gt; 3 2)
    (- 3 2)
    (+ 3 2))                           =&gt; 1
</pre>
</td></tr>
</tbody></table></center>
</td></tr>
</tbody></table><br/>
<table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody>
<tr><td><a name="g2084" class="mark"></a><a name="set!" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc2088" align="left" colspan="1"><strong id='bold2086'
>set!</strong><em id='it2087'
>  variable expression</em></td><td id="tc2089" align="right" colspan="1">syntax</td></tr>
</tbody></table>
<center id='center2097'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog2095'
>(<font color="#6959cf"><strong id='bold26385'
>define</strong></font> <font color="#6959cf"><strong id='bold26387'
>x</strong></font> 2)
(+ x 1)                                =&gt; 3
(<strong id='bold26389'
>set!</strong> x 4)                             =&gt; <em id='emph2092'
>unspecified</em>
(+ x 1)                                =&gt; 5
</pre>
</td></tr>
</tbody></table></center>
</td></tr>
</tbody></table><br/>
<table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody>
<tr><td><a name="g2101" class="mark"></a><a name="cond" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc2105" align="left" colspan="1"><strong id='bold2103'
>cond</strong><em id='it2104'
> clause clause ...</em></td><td id="tc2106" align="right" colspan="1">library syntax</td></tr>
</tbody></table>

Bigloo considers <code id='code2109'
>else</code> as a keyword. It thus ignores clauses
following an <code id='code2110'
>else</code>-clause.<br/><br/><center id='center2119'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog2117'
>(<strong id='bold26390'
>cond</strong> ((&gt; 3 2) 'greater)
      ((&lt; 3 2) 'less))                 =&gt; greater<br/><br/>(<strong id='bold26391'
>cond</strong> ((&gt; 3 3) 'greater)
      ((&lt; 3 3) 'less)
      (else 'equal))                   =&gt; equal<br/><br/>(<strong id='bold26392'
>cond</strong> ((assv 'b '((a 1) (b 2))) =&gt; cadr)
      (else #f))                       =&gt; 2
</pre>
</td></tr>
</tbody></table></center>
</td></tr>
</tbody></table><br/>
<table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody>
<tr><td><a name="g2123" class="mark"></a><a name="case" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc2127" align="left" colspan="1"><strong id='bold2125'
>case</strong><em id='it2126'
> key clause clause ...</em></td><td id="tc2128" align="right" colspan="1">library syntax</td></tr>
</tbody></table>
<center id='center2137'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog2135'
>(<strong id='bold26393'
>case</strong> (* 2 3)
  ((2 3 5 7) 'prime)
  ((1 4 6 8 9) 'composite))            =&gt; composite
(<strong id='bold26394'
>case</strong> (car '(c d))
  ((a) 'a)
  ((b) 'b))                            =&gt; <em id='emph2131'
>unspecified</em>
(<strong id='bold26395'
>case</strong> (car '(c d))
  ((a e i o u) 'vowel)
  ((w y) 'semivowel)
  (else 'consonant))                   =&gt; consonant
</pre>
</td></tr>
</tbody></table></center>
</td></tr>
</tbody></table><br/>
<table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody>
<tr><td><a name="g2141" class="mark"></a><a name="and" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc2145" align="left" colspan="1"><strong id='bold2143'
>and</strong><em id='it2144'
> test ...</em></td><td id="tc2146" align="right" colspan="1">library syntax</td></tr>
</tbody></table>
<center id='center2151'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog2149'
>(and (= 2 2) (&gt; 2 1))                  =&gt; #t
(and (= 2 2) (&lt; 2 1))                  =&gt; #f
(and 1 2 'c '(f g))                    =&gt; (f g)
(and)                                  =&gt; #t
</pre>
</td></tr>
</tbody></table></center>
</td></tr>
</tbody></table><br/> 
<table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody>
<tr><td><a name="g2155" class="mark"></a><a name="and-let*" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc2159" align="left" colspan="1"><strong id='bold2157'
>and-let*</strong><em id='it2158'
> test ...</em></td><td id="tc2160" align="right" colspan="1">bigloo syntax</td></tr>
</tbody></table>
<a name="g2163" class="mark"></a>
<center id='center2172'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog2170'
>(and-let* ((x 1) (y 2)) (cons x y))    =&gt; (1 . 2)
(and-let* ((x 1) (z #f)) x)            =&gt; #f<br/><br/>(and-let* ((my-list (compute-list)) ((not (null? my-list))))
          (do-something my-list))<br/><br/>(<font color="#6959cf"><strong id='bold26396'
>define</strong></font> (<font color="#6959cf"><strong id='bold26398'
>look-up</strong></font> key alist)
  (and-let* ((x (assq key alist))) (cdr x)))<br/><br/>(or (and-let* ((c (read-char))
               ((not (eof-object? c))))
              (string-set! some-str i c)  
              (<strong id='bold26400'
>set!</strong> i (+ 1 i)))
</pre>
</td></tr>
</tbody></table></center>

</td></tr>
</tbody></table><br/> 
<table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody>
<tr><td><a name="g2176" class="mark"></a><a name="or" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc2180" align="left" colspan="1"><strong id='bold2178'
>or</strong><em id='it2179'
> test ...</em></td><td id="tc2181" align="right" colspan="1">library syntax</td></tr>
</tbody></table>
<center id='center2186'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog2184'
>(or (= 2 2) (&gt; 2 1))                   =&gt; #t
(or (= 2 2) (&lt; 2 1))                   =&gt; #t
(or #f #f #f)                          =&gt; #f
(or (memq 'b '(a b c)) 
    (/ 3 0))                           =&gt; (b c)
</pre>
</td></tr>
</tbody></table></center>
</td></tr>
</tbody></table><br/>
<table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody>
<tr><td><a name="g2190" class="mark"></a><a name="let" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc2194" align="left" colspan="1"><strong id='bold2192'
>let</strong><em id='it2193'
> [name] (binding ...) body</em></td><td id="tc2195" align="right" colspan="1">library syntax</td></tr>
</tbody></table>
<center id='center2207'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog2205'
>(<strong id='bold26401'
>let</strong> ((x 2) (y 3))
  (* x y))                             =&gt; 6<br/><br/>(<strong id='bold26402'
>let</strong> ((x 2) (y 3))
  (<strong id='bold26403'
>let</strong> ((x 7)
        (z (+ x y)))
    (* z x)))                          =&gt; 35<br/><br/>(<strong id='bold26404'
>let</strong> loop ((l '(1 2 3)))
   (<strong id='bold26405'
>if</strong> (null? l)
       '()
       (cons (+ 1 (car l)) 
             (loop (cdr l)))))         =&gt; (2 3 4)
</pre>
</td></tr>
</tbody></table></center>

Bigloo's named let differs from R5Rs named let because <code id='code2209'
><em id='it2208'
>name</em></code>
is bound in <code id='code2211'
><em id='it2210'
>binding</em></code>. That is,<br/><br/><center id='center2217'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog2215'
>(<strong id='bold26406'
>let</strong> ((l 'a-symbol))
  (<strong id='bold26407'
>let</strong> l ((x l))
     x))                               =&gt; #&lt;procedure&gt;
</pre>
</td></tr>
</tbody></table></center>

while R5Rs states that,<br/><br/><center id='center2223'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog2221'
>(<strong id='bold26408'
>let</strong> ((l 'a-symbol))
  (<strong id='bold26409'
>let</strong> l ((x l))
     x))                               =&gt; a-symbol
</pre>
</td></tr>
</tbody></table></center>
</td></tr>
</tbody></table><br/>
<table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody>
<tr><td><a name="g2227" class="mark"></a><a name="let*" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc2231" align="left" colspan="1"><strong id='bold2229'
>let*</strong><em id='it2230'
> (binding ...) body</em></td><td id="tc2232" align="right" colspan="1">library syntax</td></tr>
</tbody></table>
<center id='center2239'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog2237'
>(<strong id='bold26410'
>let</strong> ((x 2) (y 3))
  (<strong id='bold26411'
>let*</strong> ((x 7)
         (z (+ x y)))
    (* z x)))                          =&gt; 70
</pre>
</td></tr>
</tbody></table></center>
</td></tr>
</tbody></table><br/>
<table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody>
<tr><td><a name="g2243" class="mark"></a><a name="letrec" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc2247" align="left" colspan="1"><strong id='bold2245'
>letrec</strong><em id='it2246'
> (binding ...) body</em></td><td id="tc2248" align="right" colspan="1">library syntax</td></tr>
</tbody></table>
<center id='center2258'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog2256'
>(<strong id='bold26412'
>letrec</strong> ((even?
          (<strong id='bold26413'
>lambda</strong> (n)
            (<strong id='bold26414'
>if</strong> (zero? n)
                #t
                (odd? (- n 1)))))
         (odd?
          (<strong id='bold26415'
>lambda</strong> (n)
            (<strong id='bold26416'
>if</strong> (zero? n)
                #f
                (even? (- n 1))))))
  (even? 88))   
                                       =&gt; #t
</pre>
</td></tr>
</tbody></table></center>
</td></tr>
</tbody></table><br/>
<table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody>
<tr><td><a name="g2262" class="mark"></a><a name="labels" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc2266" align="left" colspan="1"><strong id='bold2264'
>labels</strong><em id='it2265'
> ((name (arg ...) body) ...) body</em></td><td id="tc2267" align="right" colspan="1">bigloo syntax</td></tr>
</tbody></table>
The syntax is similar to the Common Lisp one [Steele90],
where created bindings are immutable.<br/><br/><center id='center2276'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog2274'
>(<strong id='bold26417'
>labels</strong> ((loop (f l acc)
               (<strong id='bold26418'
>if</strong> (null? l) 
                   (reverse! acc) 
                   (loop f (cdr l) (cons (f (car l)) acc)))))
   (loop (<strong id='bold26419'
>lambda</strong> (x) (+ 1 x)) (list 1 2 3) '()))
   =&gt; (2 3 4)
</pre>
</td></tr>
</tbody></table></center>
</td></tr>
</tbody></table><br/>
<table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody>
<tr><td><a name="g2280" class="mark"></a><a name="begin" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc2284" align="left" colspan="1"><strong id='bold2282'
>begin</strong><em id='it2283'
> expression expression ...</em></td><td id="tc2285" align="right" colspan="1">library syntax</td></tr>
</tbody></table>
<center id='center2298'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog2296'
>(<font color="#6959cf"><strong id='bold26420'
>define</strong></font> <font color="#6959cf"><strong id='bold26422'
>x</strong></font> 0)<br/><br/>(<strong id='bold26424'
>begin</strong> (<strong id='bold26425'
>set!</strong> x 5)
       (+ x 1))                        =&gt; 6<br/><br/>(<strong id='bold26426'
>begin</strong> (display <font color="red">&quot;4 plus 1 equals &quot;</font>)
       (display (+ 4 1)))              =&gt; <em id='emph2290'
>unspecified</em>
                                       -| 4 plus 1 equals 5
</pre>
</td></tr>
</tbody></table></center>
</td></tr>
</tbody></table><br/>
<table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody>
<tr><td><a name="g2302" class="mark"></a><a name="do" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc2306" align="left" colspan="1"><strong id='bold2304'
>do</strong><em id='it2305'
> ((variable init step) ...) (test expression ...) body</em></td><td id="tc2307" align="right" colspan="1">library syntax</td></tr>
</tbody></table>
<center id='center2314'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog2312'
>(do ((vec (make-vector 5))
     (i 0 (+ i 1)))
    ((= i 5) vec)
  (vector-set! vec i i))               =&gt; #(0 1 2 3 4)<br/><br/>(<strong id='bold26428'
>let</strong> ((x '(1 3 5 7 9)))
  (do ((x x (cdr x))
       (sum 0 (+ sum (car x))))
      ((null? x) sum)))                =&gt; 25
</pre>
</td></tr>
</tbody></table></center>
</td></tr>
</tbody></table><br/>
<table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody>
<tr><td><a name="g2318" class="mark"></a><a name="delay" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc2322" align="left" colspan="1"><strong id='bold2320'
>delay</strong><em id='it2321'
> expression</em></td><td id="tc2323" align="right" colspan="1">library syntax</td></tr>
</tbody></table>
</td></tr>
</tbody></table><br/>
<table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody>
<tr><td><a name="g2329" class="mark"></a><a name="quasiquote" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc2333" align="left" colspan="1"><strong id='bold2331'
>quasiquote</strong><em id='it2332'
> template</em></td><td id="tc2334" align="right" colspan="1">syntax</td></tr>
</tbody></table>
<table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc2339" align="left" colspan="1"><em id='it2338'
><tt id='tt2337'
>`</tt> template</em></td><td id="tc2340" align="right" colspan="1">syntax</td></tr>
</tbody></table>
<a name="g2344" class="mark"></a><center id='center2352'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog2350'
>`(list ,(+ 1 2) 4)                     =&gt; (list 3 4)
(<strong id='bold26429'
>let</strong> ((name 'a)) `(list ,name ',name))           
          =&gt; (list a (<strong id='bold26430'
>quote</strong> a))
`(a ,(+ 1 2) ,&#x40;(map abs '(4 -5 6)) b)           
          =&gt; (a 3 4 5 6 b)
`((<samp id='samp2346'
>foo</samp> ,(- 10 3)) ,&#x40;(cdr '(c)) . ,(car '(cons)))           
          =&gt; ((foo 7) . cons)
`#(10 5 ,(sqrt 4) ,&#x40;(map sqrt '(16 9)) 8)           
          =&gt; #(10 5 2 4 3 8)
`(a `(b ,(+ 1 2) ,(foo ,(+ 1 3) d) e) f)           
          =&gt; (a `(b ,(+ 1 2) ,(foo 4 d) e) f)
(<strong id='bold26431'
>let</strong> ((name1 'x)
      (name2 'y))
  `(a `(b ,,name1 ,',name2 d) e))           
          =&gt; (a `(b ,x ,'y d) e)
(quasiquote (list (unquote (+ 1 2)) 4))           
          =&gt; (list 3 4)
'(quasiquote (list (unquote (+ 1 2)) 4))           
          =&gt; `(list ,(+ 1 2) 4)
     i.e., (quasiquote (list (unquote (+ 1 2)) 4))
</pre>
</td></tr>
</tbody></table></center>
</td></tr>
</tbody></table><br/>
</div>
<!-- Definitions -->
<a name="Definitions"></a>
<div class="subsection-atitle"><table width="100%"><tr><td bgcolor="#ffffff"><h3><font color="#8381de">4.1.3 Definitions</font>
</h3></td></tr></table>
</div><div class="subsection">
<a name="Definitions" class="mark"></a><a name="g2355" class="mark"></a>
Global bindings are introduced by the <code id='code2357'
>define</code> form:
<table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody>
<tr><td><a name="g2359" class="mark"></a><a name="define" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc2363" align="left" colspan="1"><strong id='bold2361'
>define</strong><em id='it2362'
> variable expression</em></td><td id="tc2364" align="right" colspan="1">syntax</td></tr>
</tbody></table>
<table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc2369" align="left" colspan="1"><strong id='bold2367'
>define</strong><em id='it2368'
> (variable arg ...) body</em></td><td id="tc2370" align="right" colspan="1">syntax</td></tr>
</tbody></table>
<center id='center2378'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog2376'
>(<font color="#6959cf"><strong id='bold26432'
>define</strong></font> <font color="#6959cf"><strong id='bold26434'
>add3</strong></font>
  (<strong id='bold26436'
>lambda</strong> (x) (+ x 3)))
(add3 3)                               =&gt; 6
(<font color="#6959cf"><strong id='bold26437'
>define</strong></font> <font color="#6959cf"><strong id='bold26439'
>first</strong></font> car)
(first '(1 2))                         =&gt; 1
</pre>
</td></tr>
</tbody></table></center>
</td></tr>
</tbody></table><br/>
See <a href="./r5rs-8.html#Definitions">r5rs, Definitions</a>, for more details. The Bigloo module
language (See <a href="bigloo-4.html#Module-Declaration" class="inbound">Module Declaration</a>) enables <em id='emph2381'
>exports</em> and
<em id='emph2382'
>imports</em> of global definitions.<br/><br/><br/>

</div>
</div><br>
</div></td>
</tr></table><div class="skribe-ending">
<hr> 
<p class="ending" id='paragraph26446'
><font size="-1">
This <span class="sc">Html</span> page has been produced by 
<a href="http://www.inria.fr/mimosa/fp/Skribe" class="http">Skribe</a>.
<br/>
Last update <em id='it26444'
>Tue Jun  2 11:43:26 2009</em>.</font></p></div>
</body>
</html>