Sophie

Sophie

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

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>27. Bigloo<br/>A ``practical Scheme compiler''<br/>User manual for version 3.2b<br/>June 2009 -- Bigloo Libraries</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='center30701'
><table width="97%" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse;" frame="box" rules="none"><tbody>
<tr bgcolor="#8381de"><th id="tc30691" align="center" colspan="1"><font color="#ffffff"><strong id='bold30689'
>main page</strong></font></th></tr>
<tr bgcolor="#ffffff"><td id="tc30698" align="center" colspan="1"><table width="100%" border="0" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc30694" align="left" valign="top" colspan="1"><strong id='bold30693'
>top:</strong></td><td id="tc30695" 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='center30711'
><table width="97%" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse;" frame="box" rules="none"><tbody>
<tr bgcolor="#8381de"><th id="tc30705" align="center" colspan="1"><font color="#ffffff"><strong id='bold30703'
>Bigloo Libraries</strong></font></th></tr>
<tr bgcolor="#ffffff"><td id="tc30708" align="center" colspan="1"><table cellspacing="1" cellpadding="1" width="100%" class="toc">
<tbody>
 <tr><td valign="top" align="left">27.1</td><td colspan="4" width="100%"><a href="bigloo-28.html#Compiling-and-linking-with-a-library">Compiling and linking with a library</a></td></tr>
 <tr><td valign="top" align="left">27.2</td><td colspan="4" width="100%"><a href="bigloo-28.html#Library-and-inline-functions">Library and inline functions</a></td></tr>
 <tr><td valign="top" align="left">27.3</td><td colspan="4" width="100%"><a href="bigloo-28.html#library-and-eval">library and eval</a></td></tr>
 <tr><td valign="top" align="left">27.4</td><td colspan="4" width="100%"><a href="bigloo-28.html#library-and-repl">library and repl</a></td></tr>
 <tr><td valign="top" align="left">27.5</td><td colspan="4" width="100%"><a href="bigloo-28.html#Building-a-library">Building a library</a></td></tr>
 <tr><td valign="top" align="left">27.6</td><td colspan="4" width="100%"><a href="bigloo-28.html#A-complete-library-example">A complete library example</a></td></tr>
 <tr><td valign="top" align="left">27.7</td><td colspan="4" width="100%"><a href="bigloo-28.html#Library-and-modules">Library and modules</a></td></tr>
</tbody>
</table>
</td></tr>
</tbody></table>
</center>
<br/><br/><center id='center30721'
><table width="97%" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse;" frame="box" rules="none"><tbody>
<tr bgcolor="#8381de"><th id="tc30715" align="center" colspan="1"><font color="#ffffff"><strong id='bold30713'
>Chapters</strong></font></th></tr>
<tr bgcolor="#ffffff"><td id="tc30718" 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="Bigloo-Libraries" class="mark"></a><a name="g24387" class="mark"></a>
Bigloo libraries are collections of global bindings (global variables and
global functions). Bigloo libraries are build on the top of the host
operating system (e.g. Unix) libraries. Because Bigloo uses modules, a
library is not only a bundle of compiled codes and memory locations. A
Bigloo library is split into several files:<br/><br/><ul class="itemize" id='itemize24395'
><li>one <em id='emph24390'
>heap</em> that describes the locations of the library.
</li>
<li>several host library files.
</li>
<li>possibly, C header files.
</li>
<li>possibly, an initialization file.
</li>
</ul>
Let's consider, for example, a library that implements the
<code id='code24396'
>format</code> Common Lisp facility. Let's suppose we name this library
<code id='code24397'
>bformat</code> and let's suppose that the library number is
<code id='code24398'
>1.0</code>. Using a Unix machine, the Bigloo library will consist of
the following files:<br/><br/><ul class="itemize" id='itemize24419'
><li><code id='code24400'
>bformat.heap</code>: the heap file.
</li>
<li><code id='code24402'
>bformat.init</code>: the initialization file.
</li>
<li><code id='code24404'
>libbformat_s-1.0.a</code>, <code id='code24405'
>libbformat_s-1.0.so</code>, 
 <code id='code24406'
>libbformat_u-1.0.a</code>, <code id='code24407'
>libbformat_u-1.0.so</code>:
the Unix library files. The file names with a <code id='code24408'
>_u</code> are libraries compiled 
in <em id='emph24409'
>unsafe</em> and <em id='emph24410'
>optimized</em> mode. By convention the library using
the <code id='code24411'
>_s</code> suffix are <em id='emph24412'
>safe</em> libraries, <code id='code24413'
>_p</code> are profiling
libraries, <code id='code24414'
>_d</code> debug libraries, and <code id='code24415'
>_e</code> eval libraries.
</li>
<li><code id='code24417'
>bformat.h</code>: an include file.
</li>
</ul>
<!-- Compiling and linking with a library -->
<a name="Compiling-and-linking-with-a-library"></a>
<div class="section-atitle"><table width="100%"><tr><td bgcolor="#dedeff"><h3><font color="black">27.1 Compiling and linking with a library</font>
</h3></td></tr></table>
</div><div class="section">
<a name="g24420" class="mark"></a>From the user stand point, using a library can be made two ways:<br/><br/><ul class="itemize" id='itemize24446'
><li>Using the Bigloo <code id='code24425'
>-library <code id='code24424'
><em id='it24423'
>lib-name</em></code></code> option where 
<code id='code24427'
><em id='it24426'
>lib-name</em></code> is the name of the Bigloo library (not the name of one 
of the Unix files implementing the library). The name of the library
must be <em id='emph24428'
>lower case</em>. For instance:<br/><br/><center id='center24432'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ccffcc"><pre class="prog" id='prog24430'
>$ bigloo foo.scm -library bformat
</pre>
</td></tr>
</tbody></table></center>

</li>
<li>Using the module clause <code id='code24434'
>library</code>. This second solution prevent from
using a special compilation option. For instance, this module will
automatically compile and link with the <code id='code24435'
>bformat</code> library:<br/><br/><center id='center24444'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog24442'
>(<font color="#1919af"><strong id='bold30722'
>module</strong></font> <font color="#1919af"><strong id='bold30724'
>foo</strong></font>
   (<font color="#1919af"><strong id='bold30726'
>library</strong></font> <font color="#1919af"><strong id='bold30728'
>bformat</strong></font>))<br/><br/>...
(format ...)
</pre>
</td></tr>
</tbody></table></center>
</li>
</ul>
When a Bigloo library <code id='code24447'
>lib</code> is used, Bigloo automatically
searches if a file called <code id='code24448'
>lib.init</code> exists. If such a file
exits, it is loaded at compile-time. For instance, that file may be
used to specify compilation flags. The initialization file may affect
any of the global parameters of the Bigloo compiler. A Bigloo user
library might be needing additional system library. For instance, a
Bigloo library supporting SSL connections is likely to be needing the
a native library. Setting the compiler variable
<code id='code24449'
>*ld-port-options*</code> has this effect. For instance, one may define
an initialization file such as:<br/><br/><center id='center24455'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog24453'
>(cond-expand
   (bigloo-compile
    (<strong id='bold30730'
>set!</strong> *ld-post-options* (string-append <font color="red">&quot;-lssl &quot;</font> *ld-post-options*)))
   (bigloo-eval
    #unspecified))
</pre>
</td></tr>
</tbody></table></center>

When a Bigloo library <code id='code24456'
>lib</code> is used, the Bigloo linker
automatically looks at a library to be linked against the
application. The name of the file containing the library depends on
the operating system and the back-end used. For instance, under Unix,
for a library called <em id='emph24457'
>NAME</em>, the Bigloo linker searches for a
file called <code id='code24460'
>lib<em id='emph24458'
>NAME</em>_[s|u]-<em id='emph24459'
>VERSION</em>.a</code> or
<code id='code24464'
>lib<em id='emph24461'
>NAME</em>_[s|u]-<em id='emph24462'
>VERSION</em>.<em id='emph24463'
>DYNLIB-SUFFIX</em></code> in the
compilation linker path when using the native back-end. It searches
for a file <code id='code24467'
><em id='emph24465'
>NAME</em>_[s|u]-<em id='emph24466'
>VERSION</em>.zip</code> when the JVM
back-end is used.<br/><br/>This default <em id='emph24469'
>NAME</em> can be overridden in the initialization
file. The function <code id='code24470'
>declare-library!</code> associates a
Bigloo library name and a system name. <br/><br/><table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody>
<tr><td><a name="g24473" class="mark"></a><a name="declare-library!" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc24477" align="left" colspan="1"><strong id='bold24475'
>declare-library!</strong><em id='it24476'
> ident [attributes]</em></td><td id="tc24478" align="right" colspan="1">library procedure</td></tr>
</tbody></table>
All the attributes are optional.<br/><br/><ul class="itemize" id='itemize24511'
><li><code id='code24482'
>version:</code> the version number of the library. This defaults
to the Bigloo version number.
</li>
<li><code id='code24484'
>basename:</code> the base of the filename containing the library.
This default to the library name.
</li>
<li><code id='code24486'
>srfi:</code> a list of symbols denoting the SRFI 0 features implemented
 by this library. Registered SRFIs may be tested by the <code id='code24487'
>cond-expand</code> 
 form (see <a href="bigloo-30.html#SRFIs" class="inbound">SRFIs</a>). This defaults to an empty list.
</li>
<li><code id='code24489'
>dlopen-init:</code> a function to be invoked when the library is 
 dynamically loaded using the function <code id='code24490'
>dynamic-load</code>. This defaults
to <code id='code24491'
>#f</code>.
</li>
<li><code id='code24493'
>module-init:</code> a module to be initialized when the library is
 loaded. This defaults to <code id='code24494'
>#f</code>.
</li>
<li><code id='code24496'
>eval-init:</code> a module to be initialized for binding the library
 exports in the interpreter. This defaults to <code id='code24497'
>#f</code>.
</li>
<li><code id='code24499'
>class-init:</code> the JVM or .NET class name containing the module
 to be initialized. This defaults to <code id='code24500'
>#f</code>.
</li>
<li><code id='code24502'
>eval-init:</code> the JVM or .NET class name containing the module
 to be initialized for eval. This defaults to <code id='code24503'
>#f</code>.
</li>
<li><code id='code24505'
>init:</code> a function to be invoked when a library is loaded.
 This defaults to <code id='code24506'
>#f</code>.
</li>
<li><code id='code24508'
>eval:</code> a function to be invoked when a library is loaded for
 the interpreter. This defaults to <code id='code24509'
>#f</code>.
</li>
</ul>
Examples:<br/><br/><ul class="itemize" id='itemize24547'
><li>The following declares a library named <code id='code24513'
>foo</code>. When loaded
the Bigloo runtime system will seek file named <code id='code24514'
>libfoo_s-3.1a.so</code>, 
<code id='code24515'
>libfoo_u-3.1a.so</code>, and <code id='code24516'
>libfoo_e-3.1a.so</code>.
<center id='center24519'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog24517'
>(declare-library! 'foo) 
</pre>
</td></tr>
</tbody></table></center>

</li>
<li>The following declares a library named <code id='code24521'
>pthread</code>. When loaded
the Bigloo runtime system will seek file named <code id='code24522'
>libbigloopth_s-1.1a.so</code>, 
<code id='code24523'
>libbigloopth_u-1.1a.so</code>, and <code id='code24524'
>libbigloopth_e-1.1a.so</code>. Once
the library loaded, the SRFI-0 features <code id='code24525'
>pthread</code> and <code id='code24526'
>srfi-18</code>
will be bound. When loading the library, the two modules <code id='code24527'
>__pth_thread</code>
and <code id='code24528'
>__pth_makelib</code> will be initialized. In the JVM version these
modules are compiled in the classes <code id='code24529'
>&quot;bigloo.pthread.pthread&quot;</code>
and <code id='code24530'
>&quot;bigloo.pthread.make-lib&quot;</code>.<br/><br/><center id='center24545'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog24543'
>(declare-library! 'pthread 
                  <strong id='bold30732'
>:basename</strong> <font color="red">&quot;bigloopth&quot;</font> 
                  <strong id='bold30735'
>:version</strong> <font color="red">&quot;1.1a&quot;</font>
                  <strong id='bold30738'
>:srfi</strong> '(pthread srfi-18)
                  <strong id='bold30740'
>:module-init</strong> '__pth_thread
                  <strong id='bold30742'
>:module-eval</strong> '__pth_makelib
                  <strong id='bold30744'
>:class-init</strong> <font color="red">&quot;bigloo.pthread.pthread&quot;</font>
		  <strong id='bold30747'
>:class-eval</strong> <font color="red">&quot;bigloo.pthread.make-lib&quot;</font>)
</pre>
</td></tr>
</tbody></table></center>

</li>
</ul>
</td></tr>
</tbody></table><br/><br/><br/><table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody>
<tr><td><a name="g24552" class="mark"></a><a name="library-translation-table-add!" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc24556" align="left" colspan="1"><strong id='bold24554'
>library-translation-table-add!</strong><em id='it24555'
> ident name</em></td><td id="tc24557" align="right" colspan="1">library procedure</td></tr>
</tbody></table>
<table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc24562" align="left" colspan="1"><strong id='bold24560'
>library-translation-table-add!</strong><em id='it24561'
> ident name version</em></td><td id="tc24563" align="right" colspan="1">library procedure</td></tr>
</tbody></table>
<table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc24568" align="left" colspan="1"><strong id='bold24566'
>library-translation-table-add!</strong><em id='it24567'
> ident name version :dlopen-init initsym</em></td><td id="tc24569" align="right" colspan="1">library procedure</td></tr>
</tbody></table>

The function <code id='code24572'
>library-translation-table-add!</code> is obsolete. It should
no longer be used in new code. It is totally subsumed by
<code id='code24573'
>declare-library!</code>. The function <code id='code24574'
>library-translation-table-add!</code>
is still documented for enabling readers to understand old Bigloo source
code.<br/><br/>This function register a <code id='code24577'
><em id='it24576'
>name</em></code> for the library <code id='code24579'
><em id='it24578'
>id</em></code>. An optional
<code id='code24581'
><em id='it24580'
>version</em></code> can be specified. The optional named argument <code id='code24582'
>dlopen-init</code>
gives the base name of the initialization entry point of a library.<br/><br/>Imagine that we would like to name our <code id='code24584'
>bformat</code> library
<code id='code24585'
>bigloobformat</code>. This can be achieved by adding the following
expression in the initialization file.<br/><br/><center id='center24590'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog24588'
>(library-translation-table-add! 'bformat <font color="red">&quot;bigloobformat&quot;</font>)
</pre>
</td></tr>
</tbody></table></center>

Using this translation, on a Unix platform, the library used during
the linking will be named:
<code id='code24591'
>libbigloobformat_s-&lt;BIGLOO-VERSION&gt;.a</code>. In order to change the
<code id='code24592'
>&lt;BIGLOO-VERSION&gt;</code> to another suffix, such as <code id='code24593'
>1.0</code>, one may use:<br/><br/><center id='center24599'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog24597'
>(library-translation-table-add! 'bformat <font color="red">&quot;bigloobformat&quot;</font> <font color="red">&quot;1.0&quot;</font>)
</pre>
</td></tr>
</tbody></table></center>

In such a case, the library searched will be named
<code id='code24600'
>libbigloobformat_s-1.0.a</code>.<br/><br/>Specifying a <code id='code24602'
>#f</code> prevents the insertion of any suffix. Hence,<br/><br/><center id='center24607'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog24605'
>(library-translation-table-add! 'bformat <font color="red">&quot;bigloobformat&quot;</font> #f)
</pre>
</td></tr>
</tbody></table></center>

Instruments the compiler to look at a library named
<code id='code24608'
>libbigloobformat_s.a</code>.<br/><br/></td></tr>
</tbody></table><br/>
</div><br>
<!-- Library and inline functions -->
<a name="Library-and-inline-functions"></a>
<div class="section-atitle"><table width="100%"><tr><td bgcolor="#dedeff"><h3><font color="black">27.2 Library and inline functions</font>
</h3></td></tr></table>
</div><div class="section">
<a name="g24612" class="mark"></a>
It is illegal for libraries to include inline functions that make use of
new foreign types. By new foreign type, we mean foreign types that are
defined inside the library. A library may contains inline functions but
that inline functions must not even call function using foreign types in
their prototypes. Including inline functions making use of foreign C
type will make the compiler to fail when compiling user code. The
compiler will fail prompting type errors. A library may contains non-inline
functions that make use of new foreign types.<br/><br/></div><br>
<!-- library and eval -->
<a name="library-and-eval"></a>
<div class="section-atitle"><table width="100%"><tr><td bgcolor="#dedeff"><h3><font color="black">27.3 library and eval</font>
</h3></td></tr></table>
</div><div class="section">
<a name="g24615" class="mark"></a>
The function <code id='code24617'
>library-load</code> loads a library in the interpreter.<br/><br/><table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody>
<tr><td><a name="g24620" class="mark"></a><a name="library-exists?" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc24624" align="left" colspan="1"><strong id='bold24622'
>library-exists?</strong><em id='it24623'
> ident . path</em></td><td id="tc24625" align="right" colspan="1">library procedure</td></tr>
</tbody></table>
Checks if the library <code id='code24629'
><em id='it24628'
>ident</em></code> exists for the current back-end.<br/><br/>The regular Bigloo library paths are scanned unless optional <code id='code24632'
><em id='it24631'
>path</em></code>s
are sent to the function.
</td></tr>
</tbody></table><br/><br/><br/><table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody>
<tr><td><a name="g24637" class="mark"></a><a name="library-load" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td id="tc24641" align="left" colspan="1"><strong id='bold24639'
>library-load</strong><em id='it24640'
> ident . path</em></td><td id="tc24642" align="right" colspan="1">library procedure</td></tr>
</tbody></table>
Loads a library in the interpreter. In addition to dynamically loading
the library, this function tries to the <code id='code24645'
>_e</code> version of the library.<br/><br/>Libraries are searched in regular Bigloo library paths
unless optional <code id='code24648'
><em id='it24647'
>path</em></code>s are sent to the function.<br/><br/>This version may be used for automatically exporting binding to the
interpreter. In general, the <code id='code24650'
>_e</code> library is a simple library
that contains only one module, the module that is used to build the
heap-file. For instance, let's consider an implementation of a library
for SSL programming. This library is composed of a single implementation
module <code id='code24651'
>__ssl_ssl</code>. The library is build using a heap file:<br/><br/><center id='center24659'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog24657'
>(<font color="#1919af"><strong id='bold30754'
>module</strong></font> <font color="#1919af"><strong id='bold30756'
>__ssl_makelib</strong></font>
   (<font color="#1919af"><strong id='bold30758'
>import</strong></font> <font color="#1919af"><strong id='bold30760'
>__ssl_ssl</strong></font>))
</pre>
</td></tr>
</tbody></table></center>

Changing this file for:<br/><br/><center id='center24667'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog24665'
>(<font color="#1919af"><strong id='bold30762'
>module</strong></font> <font color="#1919af"><strong id='bold30764'
>__ssl_makelib</strong></font>
   (<font color="#1919af"><strong id='bold30766'
>import</strong></font> <font color="#1919af"><strong id='bold30768'
>__ssl_ssl</strong></font>)
   (eval   (export-all)))
</pre>
</td></tr>
</tbody></table></center>

Enables the construction of a <code id='code24668'
>_e</code> library.<br/><br/>When the system loads a dynamic library, it <em id='emph24670'
>initializes</em> it. 
For that it expects to find <em id='emph24671'
>initialization entry points</em> in the dynamic
libraries that are named after the libraries name. More precisely, for
the <code id='code24672'
>LIB_s</code> library, the loader seeks the entry point named
<code id='code24673'
>&quot;LIB_s&quot;</code> and for the <code id='code24674'
>LIB_e</code>, it seeks <code id='code24675'
>&quot;LIB_e&quot;</code>.
The name of the initialization entry of a library can be changed using
the <code id='code24676'
>declare-library!</code> function. If that named is changed,
one module of the library must contain an <code id='code24677'
>option</code> module clause
that sets the variable <code id='code24678'
>*dlopen-init*</code> with the name of the initialization
entry point.<br/><br/>Since Bigloo 3.1a, the runtime system supports a better way for
initializing libraries. <em id='emph24680'
>Initialization</em> modules can be associated
with a library. When loaded, these modules are automatically initialized.
This new method fits harmoniously with the Bigloo initialization process
and it prevents users from annotating the source code of the library.<br/><br/>For instance, if a library initialization file contains the following
declaration:<br/><br/><center id='center24686'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog24684'
>(declare-library! 'foo <strong id='bold30770'
>:module-init</strong> 'foo)
</pre>
</td></tr>
</tbody></table></center>

Then, the library must implement the <code id='code24687'
>foo</code> module.<br/><br/><center id='center24695'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog24693'
>(<font color="#1919af"><strong id='bold30772'
>module</strong></font> <font color="#1919af"><strong id='bold30774'
>foo</strong></font>
  (<font color="#1919af"><strong id='bold30776'
>import</strong></font> <font color="#1919af"><strong id='bold30778'
>...</strong></font>)
  ...)
</pre>
</td></tr>
</tbody></table></center>

In addition if the library binds variables, functions, or classes in the
interpreter then, an <code id='code24696'
>eval-init</code> clause must be added to the
class declaration:<br/><br/><center id='center24702'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog24700'
>(declare-library! 'foo <strong id='bold30780'
>:module-init</strong> 'foo <strong id='bold30782'
>:eval-init</strong> 'foo-eval)
</pre>
</td></tr>
</tbody></table></center>

Then, the module <code id='code24703'
>foo-eval</code> must be implemented in the 
<code id='code24704'
>libfoo_e</code> library.<br/><br/><center id='center24712'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog24710'
>(<font color="#1919af"><strong id='bold30784'
>module</strong></font> <font color="#1919af"><strong id='bold30786'
>foo-eval</strong></font>
  (<font color="#1919af"><strong id='bold30788'
>import</strong></font> <font color="#1919af"><strong id='bold30790'
>...</strong></font>)
  (eval (export-all)))
</pre>
</td></tr>
</tbody></table></center>
</td></tr>
</tbody></table><br/>
The standard distribution contains examples of such construction. In
particular, the multi-threading libraries <code id='code24715'
>pthread</code> and
<code id='code24716'
>fthread</code> use this facility.<br/><br/></div><br>
<!-- library and repl -->
<a name="library-and-repl"></a>
<div class="section-atitle"><table width="100%"><tr><td bgcolor="#dedeff"><h3><font color="black">27.4 library and repl</font>
</h3></td></tr></table>
</div><div class="section">
<a name="g24718" class="mark"></a>
It is possible to implement a &quot;read-eval-print-loop&quot; that is extended
with the facilities implemented inside a library. In order to make
the variables, functions, and classes of a library visible from the
interpreter, the eval <code id='code24720'
>library</code> module clause has to be used.
(see <a href="bigloo-4.html#Module-Declaration" class="inbound">Module Declaration</a>) For instance, here is a module that 
implements a &quot;repl&quot; with the <code id='code24721'
>format</code> facility available:<br/><br/><center id='center24733'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog24731'
>(<font color="#1919af"><strong id='bold30792'
>module</strong></font> <font color="#1919af"><strong id='bold30794'
>format-repl</strong></font>
   (eval (<font color="#1919af"><strong id='bold30796'
>library</strong></font> <font color="#1919af"><strong id='bold30798'
>bformat</strong></font>))
   (<font color="#1919af"><strong id='bold30800'
>library</strong></font> <font color="#1919af"><strong id='bold30802'
>bformat</strong></font>))<br/><br/><font color="#ffa600"><em id='it30804'
>;; a dummy reference to a facility of the format library</em></font>
(<strong id='bold30806'
>let</strong> ((dummy format))
   (repl)
</pre>
</td></tr>
</tbody></table></center>
<br/><br/></div><br>
<!-- Building a library -->
<a name="Building-a-library"></a>
<div class="section-atitle"><table width="100%"><tr><td bgcolor="#dedeff"><h3><font color="black">27.5 Building a library</font>
</h3></td></tr></table>
</div><div class="section">
<a name="g24735" class="mark"></a>
Bigloo libraries require several steps before being completed. <br/><br/><ul class="itemize" id='itemize24791'
><li>The first step is to build a <em id='emph24738'
>library heap</em>. This is achieved
 using a special compilation mode: <code id='code24739'
>-mkaddheap -mkaddlib -addheap -heap-library &lt;ident&gt;</code>. 
 That is, for your library you have to create a heap associated source file 
 that imports all the binding you want in your library. The heap source file
 must be <em id='emph24740'
>excluded</em> from the source files that will be used to build
 the host library.<br/><br/>Suppose we have a unique source file for the <code id='code24742'
>bformat</code> library. The module
clause of this source file is:<br/><br/><center id='center24756'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog24754'
>(<font color="#1919af"><strong id='bold30807'
>module</strong></font> <font color="#1919af"><strong id='bold30809'
>__bformat</strong></font>
   (<font color="#1919af"><strong id='bold30811'
>export</strong></font> (<font color="#1919af"><strong id='bold30813'
>format</strong></font> . args)
           format<strong id='bold30815'
>:version</strong>
           ...
   (eval   (<font color="#1919af"><strong id='bold30817'
>export</strong></font> <font color="#1919af"><strong id='bold30819'
>format</strong></font>)
           (<font color="#1919af"><strong id='bold30821'
>export</strong></font> <font color="#1919af"><strong id='bold30823'
>format</strong></font><strong id='bold30825'
>:version</strong>)
           ...
</pre>
</td></tr>
</tbody></table></center>

Prior to compiling the library, we have to create the heap associated file
(let's name it <code id='code24757'
>make-lib.scm</code>). This file could be:<br/><br/><center id='center24766'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog24764'
>(<font color="#1919af"><strong id='bold30827'
>module</strong></font> <font color="#1919af"><strong id='bold30829'
>__make-lib</strong></font>
   (<font color="#1919af"><strong id='bold30831'
>import</strong></font> (<font color="#1919af"><strong id='bold30833'
>__bformat</strong></font> <font color="red">&quot;bformat.scm&quot;</font>)))
</pre>
</td></tr>
</tbody></table></center>

Building it is simple:<br/><br/><center id='center24770'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ccffcc"><pre class="prog" id='prog24768'
>bigloo -unsafe -q -mkaddheap -mkaddlib -heap-library bformat \
     make-lib.scm -addheap bformat.heap
</pre>
</td></tr>
</tbody></table></center>

The options <code id='code24771'
>-mkaddheap</code> and <code id='code24772'
>-mkaddlib</code> tell Bigloo that it 
is compiling an heap associated file. The option <code id='code24773'
>-addheap</code> tells 
Bigloo the name of the heap file to be produced. The option 
<code id='code24774'
>-heap-library</code> instructs the compiler for the library name to be 
included inside the heap file. This name is used for checking versions 
at run-time.<br/><br/></li>
<li>The second step is to compile all the library source file. These
compilation must be done using the <code id='code24777'
>-mkaddlib</code> compilation mode. 
For example:<br/><br/><center id='center24781'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ccffcc"><pre class="prog" id='prog24779'
>bigloo -O3 -unsafe -mkaddlib              \
   -cc gcc -fsharing -q -rm               \
   -unsafev bformat.scm -o bformat_u.o -c
bigloo -O3 -mkaddlib -g -cg -cc gcc       \
   -fsharing -q -rm                       \
   -unsafev bformat.scm -o bformat.o -c
</pre>
</td></tr>
</tbody></table></center>

The first compilation produces the <em id='emph24782'
>unsafe</em> version the second the 
produced the <em id='emph24783'
>debugging</em> version.<br/><br/></li>
<li>The third step is to build the host operating system libraries. There
is no portable way to do this. This operation may looks like:<br/><br/><center id='center24789'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ccffcc"><pre class="prog" id='prog24787'
>ar qcv libbiglooformat_s.a bformat.o
ranlib libbiglooformat_s.a
ld -G -o libbiglooformat_s.so bformat.o -lm -lc
ar qcv libbiglooformat_u.a bformat_u.o
ranlib libbiglooformat_u.a
ld -G -o libbiglooformat_u.so bformat_u.o -lm -lc
</pre>
</td></tr>
</tbody></table></center>
</li>
</ul>
The last step is to create an initialization file <code id='code24792'
>bformat.init</code>:<br/><br/><center id='center24799'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog24797'
>(declare-library! 'bformat <strong id='bold30836'
>:basename</strong> <font color="red">&quot;bigloobformat&quot;</font> <strong id='bold30839'
>:version</strong> #f)
</pre>
</td></tr>
</tbody></table></center>

At this time, you are ready to use your library. The Bigloo distribution
contains library exemplar. Considering these examples as a departure point
for new libraries is probably a good idea.<br/><br/></div><br>
<!-- A complete library example -->
<a name="A-complete-library-example"></a>
<div class="section-atitle"><table width="100%"><tr><td bgcolor="#dedeff"><h3><font color="black">27.6 A complete library example</font>
</h3></td></tr></table>
</div><div class="section">
<a name="g24801" class="mark"></a>
For the means of an example let's suppose we want to design a Bigloo
library for 2d points. That library is made of three implementation
files: two C files, <code id='code24803'
>point.h</code> and <code id='code24804'
>point.c</code> and one Scheme
file <code id='code24805'
>scm-point.scm</code>. Here are defined the three files:<br/><br/><code id='code24807'
>point.h</code>:<center id='center24810'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog24808'
>struct point_2d {
   double x, y;
};
</pre>
</td></tr>
</tbody></table></center>

<code id='code24811'
>point.c</code>:<center id='center24817'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog24815'
>#include &lt;stdio.h&gt;
#include <font color="red">&quot;point.h&quot;</font><br/><br/>int print_point_2d( struct point_2d *pt ) {
   printf( <font color="red">&quot;&lt;point-2d: %g, %g&gt;&quot;</font>, pt-&gt;x, pt-&gt;y );
}
</pre>
</td></tr>
</tbody></table></center>

<code id='code24818'
>scm-point.scm</code>:<center id='center24844'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog24842'
>(<font color="#1919af"><strong id='bold30843'
>module</strong></font> <font color="#1919af"><strong id='bold30845'
>point</strong></font>
   (include <font color="red">&quot;point.sch&quot;</font>)
   (<strong id='bold30848'
>extern</strong>  (include <font color="red">&quot;point.h&quot;</font>))
   (<font color="#1919af"><strong id='bold30850'
>export</strong></font>  (<font color="#1919af"><strong id='bold30852'
>make-point</strong></font><font color="#00cf00"><strong id='bold30854'
>::s-point_2d*</strong></font> <font color="#00cf00"><strong id='bold30856'
>::double</strong></font> <font color="#00cf00"><strong id='bold30858'
>::double</strong></font>)
            (print-point             <font color="#00cf00"><strong id='bold30860'
>::s-point_2d*</strong></font>)
            (point?                  <font color="#00cf00"><strong id='bold30862'
>::obj</strong></font>))
   (eval    (export-all)))<br/><br/>(<font color="#6959cf"><strong id='bold30864'
>define</strong></font> (<font color="#6959cf"><strong id='bold30866'
>make-point</strong></font><font color="#00cf00"><strong id='bold30868'
>::s-point_2d*</strong></font> x<font color="#00cf00"><strong id='bold30870'
>::double</strong></font> y<font color="#00cf00"><strong id='bold30872'
>::double</strong></font>)
   (s-point_2d* x y))<br/><br/>(<font color="#6959cf"><strong id='bold30874'
>define</strong></font> (<font color="#6959cf"><strong id='bold30876'
>print-point</strong></font> p<font color="#00cf00"><strong id='bold30878'
>::s-point_2d*</strong></font>)
   (print_point_2d p))<br/><br/>(<font color="#6959cf"><strong id='bold30880'
>define</strong></font> (<font color="#6959cf"><strong id='bold30882'
>point?</strong></font> obj<font color="#00cf00"><strong id='bold30884'
>::obj</strong></font>)
   (s-point_2d*? obj)
   obj)
</pre>
</td></tr>
</tbody></table></center>

We want our library to be composed of the whole exported Scheme
functions. Thus the file to build the heap library could look like:<br/><br/><code id='code24846'
>make-lib.scm</code>:<center id='center24854'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog24852'
>(<font color="#1919af"><strong id='bold30886'
>module</strong></font> <font color="#1919af"><strong id='bold30888'
>__make-point-lib</strong></font>
   (<font color="#1919af"><strong id='bold30890'
>import</strong></font> (<font color="#1919af"><strong id='bold30892'
>point</strong></font> <font color="red">&quot;scm-point.scm&quot;</font>))
   (eval (export-all)))
</pre>
</td></tr>
</tbody></table></center>

Let's suppose that the <code id='code24855'
>point</code> library requires the <code id='code24856'
>libposix</code>
library. This means that any file linked with the <code id='code24857'
>point</code> library
needs to be also linked with the <code id='code24858'
>posix</code> library. Furthermore, 
programs making use of the <code id='code24859'
>point</code> library needs to include the
<code id='code24860'
>point.sch</code> file. That Scheme file needs in turn the C file 
<code id='code24861'
>point.h</code> otherwise the produced C files won't compile. The need
for the <code id='code24862'
>libposix</code> library and for the <code id='code24863'
>point.h</code> file may be
specified inside the <code id='code24864'
>point.init</code> file. For our current library,
the <code id='code24865'
>point.init</code> file could look like:<br/><br/><center id='center24883'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog24881'
>(declare-library! 'point 
                  <strong id='bold30895'
>:basename</strong> <font color="red">&quot;point&quot;</font> 
                  <strong id='bold30898'
>:srfi</strong> '(point) 
                  <strong id='bold30900'
>:eval-init</strong> '__make-point-lib)<br/><br/>(<strong id='bold30902'
>set!</strong> *ld-options*
      (string-append <font color="red">&quot;-L/usr/lib &quot;</font> *ld-options*))<br/><br/>(<strong id='bold30904'
>set!</strong> *bigloo-user-lib*
      (cons <font color="red">&quot;-lposix&quot;</font> *bigloo-user-lib*))<br/><br/>(<strong id='bold30906'
>set!</strong> *additional-include-foreign*
      (cons <font color="red">&quot;point.h&quot;</font> *additional-include-foreign*))
      
(<font color="#6959cf"><strong id='bold30908'
>define-macro</strong></font> (<font color="#6959cf"><strong id='bold30910'
>point</strong></font> x y)
   `(make-point ,x ,y))
</pre>
</td></tr>
</tbody></table></center>

This file updates some compilation variables (<code id='code24884'
>*ld-options*</code>,
<code id='code24885'
>*bigloo-user-lib*</code>, <code id='code24886'
>*additional-include-foreign*</code>) and
defines a macro: <code id='code24887'
>point</code>. Because the <code id='code24888'
>point.init</code> file will
be loaded each time a compilation require the <code id='code24889'
>point</code> library is
spawned, user code are allowed to use the <code id='code24890'
>point</code> macro. Here is an
example file making use of the <code id='code24891'
>point</code> library:<br/><br/><center id='center24902'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ffffcc"><pre class="prog" id='prog24900'
>(<font color="#1919af"><strong id='bold30912'
>module</strong></font> <font color="#1919af"><strong id='bold30914'
>example</strong></font>)<br/><br/>(<strong id='bold30916'
>let</strong> ((p (point 2.9 3.5)))
   (print <font color="red">&quot;point?: &quot;</font> (point? p))
   (print <font color="red">&quot;point?: &quot;</font> (point? 4))
   (print-point p)
   (print (eval `(point? ,p)))
   (eval `(print-point ,p))
   (print <font color="red">&quot;done...&quot;</font>))
</pre>
</td></tr>
</tbody></table></center>

To conclude that example here is the <code id='code24903'
>Makefile</code> used to compile
the <code id='code24904'
>point</code> library, heap file and one example.<br/><br/><center id='center24924'
><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody>
<tr><td bgcolor="#ccffcc"><pre class="prog" id='prog24922'
># bigloo flags
BIGLOO          = bigloo
RELEASE		= `$(BIGLOO) -eval '(begin (print *bigloo-version*) (exit 0))'`
BHEAPFLAGS      = -unsafe -q -mkaddheap -mkaddlib -v2 -heap-library point
BCOMMONFLAGGS   = -mkaddlib -fsharing -q $(VERBOSE)        \
                  -copt '$(CCOMMONFLAGS)' -cc $(CC)
BSAFEFLAGS      = $(BCOMMONFLAGGS) -cg -O3 -g -cg -unsafev \
                  -eval '(set! *indent* 4)' -rm
BUNSAFEFLAGS    = $(BCOMMONFLAGS) -O4 -unsafe<br/><br/># cigloo flags
CIGLOO          = cigloo<br/><br/># cflags
CC              = gcc
CCOMMONFLAGS    = -I.
CSAFEFLAGS      = $(CCOMMONFLAGS)
CUNSAFEFLAGS    = $(CCOMMONFLAGS) -O2<br/><br/># library objects
SAFE_OBJECT     = olib/scm-point.o olib/point.o
UNSAFE_OBJECT   = olib_u/scm-point.o olib_u/point.o<br/><br/>all: heap lib example<br/><br/>heap: point.heap<br/><br/>point.heap: point.sch scm-point.scm
        $(BIGLOO) $(BHEAPFLAGS) make-lib.scm -addheap point.heap<br/><br/>lib: lib_u lib.a<br/><br/>lib.a: olib $(SAFE_OBJECT)
        ar qcv libpoint_s-$(RELEASE).a $(SAFE_OBJECT) <br/><br/>lib_u: olib_u $(UNSAFE_OBJECT)
        ar qcv libpoint_u-$(RELEASE).a $(UNSAFE_OBJECT) <br/><br/>olib:
        mkdir olib<br/><br/>olib_u:
        mkdir olib_u<br/><br/>olib_u/scm-point.o olib/scm-point.o: scm-point.scm
        $(BIGLOO) $(BSAFEFLAGS) $(&lt;F) -o $*.o -c<br/><br/>olib_u/point.o olib/point.o: point.c
        $(CC) $(CSAFEFLAGS) $(&lt;F) -o $*.o -c<br/><br/>point.sch: point.h point.c
        cigloo $^ &gt; point.sch<br/><br/>example: heap lib
        $(BIGLOO) -v2 -L . -library point \
            -static-bigloo example.scm -o example<br/><br/>clean:
        -/bin/rm -f point.heap
        -/bin/rm -f point.sch scm-point.c
        -/bin/rm -fr olib olib_u
        -/bin/rm -f example example.c example.o
        -/bin/rm -f libpoint_s-$(RELEASE).a libpoint_u-$(RELEASE).a
</pre>
</td></tr>
</tbody></table></center>

</div><br>
<!-- Library and modules -->
<a name="Library-and-modules"></a>
<div class="section-atitle"><table width="100%"><tr><td bgcolor="#dedeff"><h3><font color="black">27.7 Library and modules</font>
</h3></td></tr></table>
</div><div class="section">
<a name="g24925" class="mark"></a>
A Bigloo library may be composed of several Bigloo modules (even if in
our example only one module was used). The modules composing the library
are free to import each other. Nevertheless, someone designing a Bigloo
library should be aware that Bigloo importation creates dependences
between modules. A module <code id='code24927'
>mod1</code> that imports a module <code id='code24928'
>mod2</code>
depends on <code id='code24929'
>mod2</code> because <code id='code24930'
>mod1</code> requires <code id='code24931'
>mod2</code> to be
initialized (i.e. <code id='code24932'
>mod1</code> calls to the initialization function of
<code id='code24933'
>mod2</code>). The result is that using <code id='code24934'
>import</code> clauses inside
modules composing a library may create a lot of dependencies between the
object files that are used to build the associated Unix
library. Dependencies should be avoided because they make the Unix
linkers unable to produce small stand-alone programs. Instead of
<code id='code24935'
>import</code> clauses, <code id='code24936'
>use</code> clauses should be
preferred. <code id='code24937'
>Use</code> clauses do not create dependencies because a
module <code id='code24938'
>mod1</code> that <code id='code24939'
>use</code>s a second module <code id='code24940'
>mod2</code> does not
require <code id='code24941'
>mod2</code> to be initialized. Of course, it may happen
situations where the initialization is mandatory and thus, the
<code id='code24942'
>import</code> must not be replaced with a <code id='code24943'
>use</code> clause. The source
code of the Bigloo library makes use of <code id='code24944'
>import</code> and <code id='code24945'
>use</code>
clauses. The Bigloo standard library should be studied as an example.<br/><br/><br/><br/>

</div><br>
</div></td>
</tr></table><div class="skribe-ending">
<hr> 
<p class="ending" id='paragraph30925'
><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='it30923'
>Tue Jun  2 11:43:27 2009</em>.</font></p></div>
</body>
</html>