<!-- 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>21. Bigloo<br/>A ``practical Scheme compiler''<br/>User manual for version 3.2b<br/>June 2009 -- Eval and code interpretation</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='center29929' ><table width="97%" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse;" frame="box" rules="none"><tbody> <tr bgcolor="#8381de"><th id="tc29919" align="center" colspan="1"><font color="#ffffff"><strong id='bold29917' >main page</strong></font></th></tr> <tr bgcolor="#ffffff"><td id="tc29926" align="center" colspan="1"><table width="100%" border="0" style="border-collapse: collapse;" frame="void" rules="none"><tbody> <tr><td id="tc29922" align="left" valign="top" colspan="1"><strong id='bold29921' >top:</strong></td><td id="tc29923" 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='center29939' ><table width="97%" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse;" frame="box" rules="none"><tbody> <tr bgcolor="#8381de"><th id="tc29933" align="center" colspan="1"><font color="#ffffff"><strong id='bold29931' >Eval and code interpretation</strong></font></th></tr> <tr bgcolor="#ffffff"><td id="tc29936" align="center" colspan="1"><table cellspacing="1" cellpadding="1" width="100%" class="toc"> <tbody> <tr><td valign="top" align="left">21.1</td><td colspan="4" width="100%"><a href="bigloo-22.html#Eval-compliance">Eval compliance</a></td></tr> <tr><td valign="top" align="left">21.2</td><td colspan="4" width="100%"><a href="bigloo-22.html#Eval-standard-functions">Eval standard functions</a></td></tr> <tr><td valign="top" align="left">21.3</td><td colspan="4" width="100%"><a href="bigloo-22.html#Eval-command-line-options">Eval command line options</a></td></tr> <tr><td valign="top" align="left">21.4</td><td colspan="4" width="100%"><a href="bigloo-22.html#Eval-and-the-foreign-interface">Eval and the foreign interface</a></td></tr> </tbody> </table> </td></tr> </tbody></table> </center> <br/><br/><center id='center29949' ><table width="97%" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse;" frame="box" rules="none"><tbody> <tr bgcolor="#8381de"><th id="tc29943" align="center" colspan="1"><font color="#ffffff"><strong id='bold29941' >Chapters</strong></font></th></tr> <tr bgcolor="#ffffff"><td id="tc29946" 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="Eval" class="mark"></a><a name="g22085" class="mark"></a><a name="g22087" class="mark"></a> This chapter describes the Bigloo evaluator.<br/><br/> <!-- Eval compliance --> <a name="Eval-compliance"></a> <div class="section-atitle"><table width="100%"><tr><td bgcolor="#dedeff"><h3><font color="black">21.1 Eval compliance</font> </h3></td></tr></table> </div><div class="section"> <a name="Eval-compliance" class="mark"></a><a name="g22090" class="mark"></a><a name="g22092" class="mark"></a> Bigloo includes an interpreter. Unfortunately, the language accepted by the interpreter is a proper subset of that accepted by the compiler. The main differences are:<br/><br/><ul class="itemize" id='itemize22098' ><li>No foreign objects can be handled by interpreter. </li> <li>Classes of the object system cannot be declared within interpreted code. </li> <li>The interpreter ignores modules, and has a unique global environment. </li> </ul> Compiled code and interpreted code can be mixed together. That is, interpreted code is allowed to call compiled code and vice versa. This connection can be use to circumvent the missing features of the interpreter (see Section see <a href="bigloo-4.html#Module-Declaration" class="inbound">Module Declaration</a>, for a description of how to connect compiled and interpreted code).<br/><br/>By default the evaluator assumes that operators from the standard library (e.g., <code id='code22100' >+</code>, <code id='code22101' >car</code>) are immutable. Hence, it optimizes these operators calls. This optimization can be disables using the <code id='code22102' >bigloo-eval-strict-module</code> parameter described in the chapter describing the parameters (see see <a href="bigloo-24.html#Parameters" class="inbound">Parameters</a>). <br/><br/></div><br> <!-- Eval standard functions --> <a name="Eval-standard-functions"></a> <div class="section-atitle"><table width="100%"><tr><td bgcolor="#dedeff"><h3><font color="black">21.2 Eval standard functions</font> </h3></td></tr></table> </div><div class="section"> <a name="Eval-standard-functions" class="mark"></a><a name="g22104" class="mark"></a> <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="tc22108" align="left" colspan="1"><strong id='bold22106' >eval</strong><em id='it22107' > exp [env]</em></td><td id="tc22109" align="right" colspan="1">procedure</td></tr> </tbody></table> This form evaluates <code id='code22113' ><em id='it22112' >exp</em></code>. The second argument is optional. It can be the evaluation of one of these three function forms: <center id='center22116' ><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody> <tr><td bgcolor="#ffffcc"><pre class="prog" id='prog22114' >(scheme-report-environment 5) (null-environment 5) (interaction-environment) </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="g22120" class="mark"></a><a name="scheme-report-environment" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody> <tr><td id="tc22124" align="left" colspan="1"><strong id='bold22122' >scheme-report-environment</strong><em id='it22123' > version</em></td><td id="tc22125" align="right" colspan="1">procedure</td></tr> </tbody></table> <a name="g22129" class="mark"></a><a name="null-environment" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody> <tr><td id="tc22135" align="left" colspan="1"><strong id='bold22131' >null-environment</strong><em id='it22134' > <code id='code22133' ><em id='it22132' >version</em></code></em></td><td id="tc22136" align="right" colspan="1">procedure</td></tr> </tbody></table> <a name="g22140" class="mark"></a><a name="interaction-environment" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody> <tr><td id="tc22146" align="left" colspan="1"><strong id='bold22142' >interaction-environment</strong><em id='it22145' > <code id='code22144' ><em id='it22143' >version</em></code></em></td><td id="tc22147" align="right" colspan="1">procedure</td></tr> </tbody></table> These three procedures have the definitions given in the R5RS so see info-file `r5rs.info', 6.5 Eval, for more details. </td></tr> </tbody></table><br/> <table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody> <tr><td><a name="g22153" class="mark"></a><a name="byte-code-compile" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody> <tr><td id="tc22157" align="left" colspan="1"><strong id='bold22155' >byte-code-compile</strong><em id='it22156' > exp [env (default-environment)]</em></td><td id="tc22158" align="right" colspan="1">bigloo procedure</td></tr> </tbody></table> <a name="g22162" class="mark"></a><a name="byte-code-run" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody> <tr><td id="tc22166" align="left" colspan="1"><strong id='bold22164' >byte-code-run</strong><em id='it22165' > byte-code</em></td><td id="tc22167" align="right" colspan="1">bigloo procedure</td></tr> </tbody></table> The function <code id='code22170' >byte-code-compile</code> compiles a Scheme expression into a sequence of byte codes that is implemented as a string. The function <code id='code22171' >byte-code-run</code> execute such a sequence. </td></tr> </tbody></table><br/> <table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody> <tr><td><a name="g22175" class="mark"></a><a name="repl" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody> <tr><td id="tc22179" align="left" colspan="1"><strong id='bold22177' >repl</strong><em id='it22178' ></em></td><td id="tc22180" align="right" colspan="1">bigloo procedure</td></tr> </tbody></table> <a name="g22183" class="mark"></a>This invokes the <code id='code22186' ><em id='it22185' >read-eval-print</em></code> loop. Several <code id='code22187' >repl</code> can be embedded.<br/><br/>The <code id='code22189' >repl</code> function can be used to implement custom Bigloo interpreters. For instance, one may write:<br/><br/><center id='center22195' ><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody> <tr><td bgcolor="#ffffcc"><pre class="prog" id='prog22193' >(<font color="#1919af"><strong id='bold29950' >module</strong></font> <font color="#1919af"><strong id='bold29952' >repl</strong></font>) (repl) </pre> </td></tr> </tbody></table></center> When compiled, this will deliver an executable containingthe sole Bigloo interpreter. </td></tr> </tbody></table><br/> <table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody> <tr><td><a name="g22199" class="mark"></a><a name="quit" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody> <tr><td id="tc22203" align="left" colspan="1"><strong id='bold22201' >quit</strong><em id='it22202' > </em></td><td id="tc22204" align="right" colspan="1">bigloo procedure</td></tr> </tbody></table> This exits from the currently running <code id='code22207' >repl</code>. If the current <code id='code22208' >repl</code> is the first one then this function ends the interpreter. </td></tr> </tbody></table><br/> <table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody> <tr><td><a name="g22212" class="mark"></a><a name="set-prompter!" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody> <tr><td id="tc22216" align="left" colspan="1"><strong id='bold22214' >set-prompter!</strong><em id='it22215' > proc</em></td><td id="tc22217" align="right" colspan="1">bigloo procedure</td></tr> </tbody></table> The argument <code id='code22221' ><em id='it22220' >proc</em></code> has to be a procedure of one argument and invoking this function sets the <code id='code22222' >repl</code> prompter. That is, to display its prompt, <code id='code22223' >repl</code> invokes <code id='code22225' ><em id='it22224' >proc</em></code> giving it the nesting level of the current loop as its argument. </td></tr> </tbody></table><br/> <table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody> <tr><td><a name="g22229" class="mark"></a><a name="get-prompter" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody> <tr><td id="tc22233" align="left" colspan="1"><strong id='bold22231' >get-prompter</strong><em id='it22232' ></em></td><td id="tc22234" align="right" colspan="1">bigloo procedure</td></tr> </tbody></table> Returns the current <code id='code22237' >repl</code> prompter. </td></tr> </tbody></table><br/> <table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody> <tr><td><a name="g22241" class="mark"></a><a name="set-repl-printer!" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody> <tr><td id="tc22245" align="left" colspan="1"><strong id='bold22243' >set-repl-printer!</strong><em id='it22244' > proc</em></td><td id="tc22246" align="right" colspan="1">bigloo procedure</td></tr> </tbody></table> The argument <code id='code22250' ><em id='it22249' >proc</em></code> has to be a procedure accepting one or two arguments. This function sets the <code id='code22251' >repl</code> display function. That is, to display the result of its evaluations, <code id='code22252' >repl</code> invokes <code id='code22254' ><em id='it22253' >proc</em></code> giving it the evaluated expression as first argument and the current output port (or a file in case of transcript) as second argument. <code id='code22255' >Set-repl-printer!</code> returns the former <code id='code22256' >repl</code> display function.<br/><br/>For instance, one may write:<br/><br/><center id='center22269' ><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody> <tr><td bgcolor="#ffffcc"><pre class="prog" id='prog22267' >1<strong id='bold29954' >:=></strong> (<font color="#6959cf"><strong id='bold29956' >define</strong></font> <font color="#6959cf"><strong id='bold29958' >x</strong></font> (cons 1 2)) -| X 1<strong id='bold29960' >:=></strong> (<font color="#6959cf"><strong id='bold29962' >define</strong></font> <font color="#6959cf"><strong id='bold29964' >y</strong></font> (cons x x)) -| Y 1<strong id='bold29966' >:=></strong> y -| (#0=(1 . 2) . #0#) 1<strong id='bold29968' >:=></strong> (set-repl-printer! display) -| #<procedure<strong id='bold29970' >:83b8c70.-2></strong> 1<strong id='bold29972' >:=></strong> y -| ((1 . 2) 1 . 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="g22273" class="mark"></a><a name="native-repl-printer" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody> <tr><td id="tc22277" align="left" colspan="1"><strong id='bold22275' >native-repl-printer</strong><em id='it22276' ></em></td><td id="tc22278" align="right" colspan="1">bigloo procedure</td></tr> </tbody></table> Returns the native (default) <code id='code22281' >repl</code> display function. </td></tr> </tbody></table><br/> <table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody> <tr><td><a name="g22285" class="mark"></a><a name="expand" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody> <tr><td id="tc22289" align="left" colspan="1"><strong id='bold22287' >expand</strong><em id='it22288' > exp</em></td><td id="tc22290" align="right" colspan="1">bigloo procedure</td></tr> </tbody></table> Returns the value of <code id='code22294' ><em id='it22293' >exp</em></code> after all macro expansions have been performed. </td></tr> </tbody></table><br/> <table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody> <tr><td><a name="g22298" class="mark"></a><a name="expand-once" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody> <tr><td id="tc22302" align="left" colspan="1"><strong id='bold22300' >expand-once</strong><em id='it22301' > exp</em></td><td id="tc22303" align="right" colspan="1">bigloo procedure</td></tr> </tbody></table> Returns the value of <code id='code22307' ><em id='it22306' >exp</em></code> after one macro expansion has been performed. </td></tr> </tbody></table><br/> It is possible to specify files which have to be loaded when the interpreter is invoked. For this, see section see <a href="bigloo-31.html#Compiler-Description" class="inbound">Compiler Description</a>.<br/><br/>If a Bigloo file starts with the line: <center id='center22313' ><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody> <tr><td bgcolor="#ffffcc"><pre class="prog" id='prog22311' > #! bigloo-command-name </pre> </td></tr> </tbody></table></center> and if this file is executable (in the meaning of the system) and if the user tries to execute it, Bigloo will evaluate it. Note also that SRFI-22 support enables to run any Unix interpreter (see <a href="bigloo-30.html#SRFIs" class="inbound">SRFIs</a>).<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="tc22317" align="left" colspan="1"><strong id='bold22315' >load</strong><em id='it22316' > filename</em></td><td id="tc22318" align="right" colspan="1">bigloo procedure</td></tr> </tbody></table> <a name="g22322" class="mark"></a><a name="loadq" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody> <tr><td id="tc22326" align="left" colspan="1"><strong id='bold22324' >loadq</strong><em id='it22325' > filename</em></td><td id="tc22327" align="right" colspan="1">bigloo procedure</td></tr> </tbody></table> <code id='code22331' ><em id='it22330' >Filename</em></code> should be a string naming an existing file which contains Bigloo source code. This file is searched in the current directory and in all the directories mentioned in the variable <code id='code22332' >*load-path*</code>. The <code id='code22333' >load</code> procedure reads expressions and definitions from the file, evaluating them sequentially. If the file loaded is a module (i.e. if it begins with a regular module clause), load behaves as module initialization. Otherwise, this function returns the result of the last evaluation. The function <code id='code22334' >oadq</code> differs from the function <code id='code22335' >load</code> in the sense that <code id='code22336' >loadq</code> does not print any intermediate evaluations.<br/><br/>Both functions return the full path of the loaded file. </td></tr> </tbody></table><br/> <table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody> <tr><td><a name="g22341" class="mark"></a><a name="loada" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody> <tr><td id="tc22345" align="left" colspan="1"><strong id='bold22343' >loada</strong><em id='it22344' > filename</em></td><td id="tc22346" align="right" colspan="1">bigloo procedure</td></tr> </tbody></table> Loads an ``access file'', which allows the interpreter to find the modules imported by a loaded module. It returns the full path of the loaded file. </td></tr> </tbody></table><br/> <table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody> <tr><td><a name="g22352" class="mark"></a><a name="*load-path*" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody> <tr><td id="tc22356" align="left" colspan="1"><strong id='bold22354' >*load-path*</strong><em id='it22355' ></em></td><td id="tc22357" align="right" colspan="1">bigloo variable</td></tr> </tbody></table> A list of search paths for the <code id='code22360' >load</code> functions. </td></tr> </tbody></table><br/> <table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody> <tr><td><a name="g22364" class="mark"></a><a name="dynamic-load" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody> <tr><td id="tc22368" align="left" colspan="1"><strong id='bold22366' >dynamic-load</strong><em id='it22367' > filename #!optional (init init-point)</em></td><td id="tc22369" align="right" colspan="1">bigloo procedure</td></tr> </tbody></table> Loads a shared library named <code id='code22372' >filename</code>. <br/><br/><em id='emph22374' >Important note: </em> The function <code id='code22375' >dynamic-load</code> can only be used from interpreters linked against dynamic libraries. In particular, the <code id='code22376' >dynamic-load</code> function can be issued from the <code id='code22377' >bigloo</code> command if and only if the option <code id='code22378' >--sharedcompiler=yes</code> has been used when configuring Bigloo. If the <code id='code22379' >bigloo</code> command is not linked against dynamic libraries and if <code id='code22380' >dynamic-load</code> is required inside a read-eval-print loop (REPL) it exists a simple workaround. It consists in implementing a new REPL and linking it against dynamic libraries. This can be done as:<br/><br/><center id='center22384' ><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody> <tr><td bgcolor="#ccffcc"><pre class="prog" id='prog22382' >$ cat > new-repl.scm <<EOF (module new-repl) (repl) EOF $ bigloo new-repl.scm -o new-repl $ new-repl 1:=> (dynamic-load ...) </pre> </td></tr> </tbody></table></center> <br/><br/><br/>The function <code id='code22387' >dynamic-load</code> returns the name of the loaded library. If <code id='code22389' ><em id='it22388' >init-point</em></code> is specified and if it is a string and if the library defines a function named <code id='code22390' >init-point</code>, this function is called when the library is loaded. <code id='code22392' ><em id='it22391' >Init-point</em></code> is a C identifier, not a Scheme identifier. In order to set the C name a Scheme function, use the extern <code id='code22393' >export</code> clause (see Section see <a href="bigloo-26.html#C-Interface" class="inbound">C Interface</a>). If the <code id='code22395' ><em id='it22394' >init-point</em></code> is provided and is not a string, no initialization function is called after the library is loaded. If the <code id='code22397' ><em id='it22396' >init-point</em></code> value is not provided, once the library is loaded, <code id='code22398' >dynamic-load</code> uses the Bigloo default entry point. Normally you should <em id='emph22399' >not</em> provide an <code id='code22401' ><em id='it22400' >init-point</em></code> to <code id='code22402' >dynamic-load</code> unless you known what you are doing. When producing C code, to force the Bigloo compiler to emit such a default entry point, use the <code id='code22403' >-dload-sym</code> compilation option (see Section see <a href="bigloo-31.html#Compiler-Description" class="inbound">Compiler Description</a>). This option is useless when using the JVM code generator. Let's assume a Linux system and two Bigloo modules. The first:<br/><br/><center id='center22417' ><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody> <tr><td bgcolor="#ffffcc"><pre class="prog" id='prog22415' >(<font color="#1919af"><strong id='bold29974' >module</strong></font> <font color="#1919af"><strong id='bold29976' >mod1</strong></font> (eval (<font color="#1919af"><strong id='bold29978' >export</strong></font> <font color="#1919af"><strong id='bold29980' >foo</strong></font>)) (<font color="#1919af"><strong id='bold29982' >export</strong></font> (<font color="#1919af"><strong id='bold29984' >foo</strong></font> x)))<br/><br/>(<font color="#6959cf"><strong id='bold29986' >define</strong></font> (<font color="#6959cf"><strong id='bold29988' >foo</strong></font> x) (print <font color="red">"foo: "</font> x))<br/><br/>(foo 4) </pre> </td></tr> </tbody></table></center> The second:<br/><br/><center id='center22434' ><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody> <tr><td bgcolor="#ffffcc"><pre class="prog" id='prog22432' >(<font color="#1919af"><strong id='bold29991' >module</strong></font> <font color="#1919af"><strong id='bold29993' >mod2</strong></font> (<font color="#1919af"><strong id='bold29995' >import</strong></font> (<font color="#1919af"><strong id='bold29997' >mod1</strong></font> <font color="red">"mod1.scm"</font>)) (eval (<font color="#1919af"><strong id='bold30000' >export</strong></font> <font color="#1919af"><strong id='bold30002' >bar</strong></font>)) (<font color="#1919af"><strong id='bold30004' >export</strong></font> (<font color="#1919af"><strong id='bold30006' >bar</strong></font> x)))<br/><br/>(<font color="#6959cf"><strong id='bold30008' >define</strong></font> (<font color="#6959cf"><strong id='bold30010' >bar</strong></font> x) (print <font color="red">"bar: "</font> x))<br/><br/>(bar 5) </pre> </td></tr> </tbody></table></center> If these modules are compiled as:<br/><br/><center id='center22438' ><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody> <tr><td bgcolor="#ccffcc"><pre class="prog" id='prog22436' >$ bigloo mod1.scm -c -o mod1.o $ bigloo mod2.scm -c -o mod2.o -dload-sym </pre> </td></tr> </tbody></table></center> Then, if a shared library is built using these two modules (note that on non Linux systems, a different command line is required):<br/><br/><center id='center22442' ><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody> <tr><td bgcolor="#ccffcc"><pre class="prog" id='prog22440' >$ ld -G -o lib.so mod1.o mod2.o </pre> </td></tr> </tbody></table></center> Then, <code id='code22443' >lib.so</code> cant be dynamically loaded and the variables it defines used such as :<br/><br/><center id='center22449' ><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody> <tr><td bgcolor="#ffffcc"><pre class="prog" id='prog22447' >$ bigloo -i (dynamic-load <font color="red">"lib.so"</font>) -| foo: 4 bar: 5 1<strong id='bold30014' >:=></strong> (foo 6) -| foo: 7 </pre> </td></tr> </tbody></table></center> As the example illustrates, when Bigloo modules are dynamically loaded, they are initialized. This initialization is ensure <em id='emph22450' >only</em> if <code id='code22451' >dynamic-load</code> is called with exactly one parameter. If <code id='code22452' >dynamic-load</code> is called with two parameters, it is of the responsibility of the program to initialize the dynamically loaded module before using any Scheme reference.<br/><br/><em id='emph22454' >Note: </em> In order to let the loaded module accesses the variables defined by the loader application, special compilation flags must be used (e.g., <code id='code22455' >-rdynamic</code> under the Linux operating system). <code id='code22456' >Dynamic-load</code> is implemented on the top of the <code id='code22457' >dlopen</code> facility. For more information read the <code id='code22458' >dlopen</code> and <code id='code22459' >ld</code> manuals.<br/><br/></td></tr> </tbody></table><br/> <table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody> <tr><td><a name="g22464" class="mark"></a><a name="dynamic-unload" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody> <tr><td id="tc22468" align="left" colspan="1"><strong id='bold22466' >dynamic-unload</strong><em id='it22467' > filename</em></td><td id="tc22469" align="right" colspan="1">bigloo procedure</td></tr> </tbody></table> On the operating system that supports this facility, unloads a shared library. Returns <code id='code22472' >#t</code> on success. Returns <code id='code22473' >#f</code> otherwise. </td></tr> </tbody></table><br/> <table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody> <tr><td><a name="g22477" class="mark"></a><a name="*dynamic-load-path*" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody> <tr><td id="tc22481" align="left" colspan="1"><strong id='bold22479' >*dynamic-load-path*</strong><em id='it22480' ></em></td><td id="tc22482" align="right" colspan="1">bigloo variable</td></tr> </tbody></table> A list of search paths for the <code id='code22485' >dynamic-load</code> functions. </td></tr> </tbody></table><br/><br/><br/><table cellspacing="0" class="frame" cellpadding="10" border="1" width="100%"><tbody> <tr><td><a name="g22490" class="mark"></a><a name="transcript-on" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody> <tr><td id="tc22494" align="left" colspan="1"><strong id='bold22492' >transcript-on</strong><em id='it22493' > filename</em></td><td id="tc22495" align="right" colspan="1">procedure</td></tr> </tbody></table> <a name="g22499" class="mark"></a><a name="transcript-off" class="mark"></a><table width="100%" style="border-collapse: collapse;" frame="void" rules="none"><tbody> <tr><td id="tc22503" align="left" colspan="1"><strong id='bold22501' >transcript-off</strong><em id='it22502' > </em></td><td id="tc22504" align="right" colspan="1">procedure</td></tr> </tbody></table> </td></tr> </tbody></table><br/> </div><br> <!-- Eval command line options --> <a name="Eval-command-line-options"></a> <div class="section-atitle"><table width="100%"><tr><td bgcolor="#dedeff"><h3><font color="black">21.3 Eval command line options</font> </h3></td></tr></table> </div><div class="section"> <a name="Eval-command-line-options" class="mark"></a><a name="g22509" class="mark"></a> This section presents the Bigloo compiler options that impact the interaction between compiled and interpreted code. The whole list of the Bigloo compiler options can be found in <a href="bigloo-31.html#Compiler-Description" class="inbound">The Bigloo command line</a>.<br/><br/><ul class="itemize" id='itemize22526' ><li><code id='code22512' >-i</code> Don't compile a module, interpret it! </li> <li><code id='code22514' >-export-all</code> Make all the bindings <em id='emph22515' >defined</em> by the compiled module available from the interpreter. </li> <li><code id='code22517' >-export-export</code> Make all the bindings <em id='emph22518' >exported</em> by the compiled module available from the interpreter. </li> <li><code id='code22520' >-export-mutable</code> Make all the bindings <em id='emph22521' >exported</em> by the compiled module mutable from outside the module. This option is <em id='emph22522' >dangerous</em>! Either all the modules composing the application must be compiled with or without <code id='code22523' >-export-mutable</code>. It is impossible to mix <code id='code22524' >-export-mutable</code> enabled and disabled compilations. </li> </ul> </div><br> <!-- Eval and the foreign interface --> <a name="Eval-and-the-foreign-interface"></a> <div class="section-atitle"><table width="100%"><tr><td bgcolor="#dedeff"><h3><font color="black">21.4 Eval and the foreign interface</font> </h3></td></tr></table> </div><div class="section"> <a name="Eval-and-the-foreign-interface" class="mark"></a><a name="g22527" class="mark"></a> To be able to get access to foreign functions within the Bigloo interpreter, some extra measurements have to be taken. The foreign functions have to be present in the interpreter binary, which means you have to compile a custom interpreter. This is described in Section <a href="bigloo-26.html#Using-C-bindings-within-the-interpreter" class="inbound">Using C bindings within the interpreter</a>. </div><br> </div></td> </tr></table><div class="skribe-ending"> <hr> <p class="ending" id='paragraph30021' ><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='it30019' >Tue Jun 2 11:43:27 2009</em>.</font></p></div> </body> </html>