Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[9d04bd]: impnotes / require.html Maximize Restore History

Download this file

require.html    38 lines (35 with data), 9.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>24.3. Function REQUIRE</title><link rel="stylesheet" href="impnotes.css" type="text/css" /><link rev="made" href="mailto:clisp-list@lists.sourceforge.net" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot_8465" /><link rel="home" href="index.html" title="Implementation Notes for GNU CLISP" /><link rel="up" href="system.html" title="Chapter 24. System Construction" /><link rel="prev" href="compile-file-path.html" title="24.2. Function COMPILE-FILE-PATHNAME" /><link rel="next" href="loadfile.html" title="24.4. Function LOAD" /><link rel="copyright" href="legalese.html" title="Legal Status of the CLISP Implementation Notes" /><meta name="date" content="'generated: 2009-07-28 12:48:49-04:00'" /><link rel="author" title="Authors" href="index.html#authors" /><link rel="contents" title="Table of Contents" href="index.html" /><link rel="glossary" href="glossary.html" /><link rel="help" href="faq.html#faq-help" title="How do I ask for help?" /><link rel="home" title="Home" href="http://clisp.cons.org" /><link rel="index" href="idx.html" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">24.3. Function <code class="function">REQUIRE</code></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="compile-file-path.html">Prev</a> </td><th width="60%" align="center">Chapter 24. System Construction </th><td width="20%" align="right"> <a accesskey="n" href="loadfile.html">Next</a></td></tr></table><hr /></div><div class="section" title="24.3. Function REQUIRE"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="require"></a>24.3. Function <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/fun_providecm_require.html" target="_top"><code class="function">REQUIRE</code></a></h2></div></div></div><p>The function <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/fun_providecm_require.html" target="_top"><code class="function">REQUIRE</code></a> receives as the optional argument either
a <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_pathname.html" target="_top"><code class="classname">PATHNAME</code></a> or a <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_list.html" target="_top"><code class="classname">LIST</code></a> of <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_pathname.html" target="_top"><code class="classname">PATHNAME</code></a>s: files to be <a href="loadfile.html" class="olink"><code class="function">LOAD</code></a>ed
if the required module is not already present.</p><p>At compile time, <code class="code">(<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/fun_providecm_require.html" target="_top"><code class="function">REQUIRE</code></a> <code class="filename">#P"foo"</code>)</code>
forms are treated specially: <a href="loadfile.html#load-paths" class="olink"><code class="varname">CUSTOM:*LOAD-PATHS*</code></a> is searched for
<code class="filename">#P"foo.lisp"</code> <span class="strong"><strong>and</strong></span> <code class="filename">#P"foo.lib"</code>.
If the latest such file is a <code class="filename">#P".lisp"</code>, it is compiled;
otherwise the <a class="link" href="require.html" title="24.3. Function REQUIRE"><code class="filename">#P".lib"</code></a> is loaded.</p><p>The <a class="link" href="require.html" title="24.3. Function REQUIRE"><code class="filename">#P".lib"</code></a> is a <span class="quote"><span class="quote">header</span></span> file which contains the
constant, variable, inline and macro definitions necessary for
compilation of the files that <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/fun_providecm_require.html" target="_top"><code class="function">REQUIRE</code></a> this file, but not the function
definitions and calls that are not necessary for that.
Thus it is <span class="strong"><strong>not</strong></span> necessary to either enclose <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/fun_providecm_require.html" target="_top"><code class="function">REQUIRE</code></a> forms in
<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/speope_eval-when.html" target="_top"><code class="function">EVAL-WHEN</code></a> or to load the required files in the makefiles: if you have
two files, <code class="filename">#P"foo.lisp"</code> and <code class="filename">#P"bar.lisp"</code>, and the
latter requires the former, you can write in your <code class="filename">Makefile</code>:
</p><pre class="programlisting">
all: foo.fas bar.fas
foo.fas: foo.lisp
clisp -c foo
bar.fas: bar.lisp foo.fas
clisp -c bar
</pre><p>
instead of the more cumbersome (and slower, since <a class="link" href="require.html" title="24.3. Function REQUIRE"><code class="filename">#P".lib"</code></a>s are
usually smaller and load faster that <code class="filename">#P".fas"</code>s):
</p><pre class="programlisting">
bar.fas: bar.lisp foo.fas
clisp -i foo -c bar
</pre><p>
Thus, you do not need to <code class="code">(<a href="loadfile.html" class="olink"><code class="function">LOAD</code></a> <code class="filename">#P"foo"</code>)</code> in order
to <code class="code">(<a href="compilefile.html" class="olink"><code class="function">COMPILE-FILE</code></a> <code class="filename">#P"bar.lisp"</code>)</code>.
If memory is tight, and if <code class="filename">#P"foo.lisp"</code> contains only a few inline
functions, macros, constants or variables, this is a space and time
saver. If <code class="filename">#P"foo.lisp"</code> does a lot of initializations or side effects
when being loaded, this is important as well.</p></div><div class="bookinfo"><hr /><table width="100%" summary="impnotes meta info"><th><td align="left">These notes document <a class="ulink" href="http://clisp.cons.org" target="_top"><span class="command"><strong>CLISP</strong></span></a> version 2.48</td><td align="right">Last modified: 2009-07-28</td></th></table></div><div class="custom-footer"><hr /><table width="100%"><tr><td align="left"><a href="http://clisp.cons.org"><img src="clisp.png" width="48" height="48" alt="[CLISP home]" /></a></td><td align="center"><a href="https://sourceforge.net/donate/index.php?group_id=1355"><img src="http://images.sourceforge.net/images/project-support.jpg" width="88" height="32" alt="[Support CLISP]" /></a></td><td align="right"><a href="https://sourceforge.net/projects/clisp"><img width="120" height="30" alt="[SourceForge]" src="http://sflogo.sourceforge.net/sflogo.php?group_id=1355&amp;type=12&amp;page=require" /></a></td></tr></table></div><hr /><form method="get" action="http://www.google.com/custom" target="_top"><table width="100%" border="0"><tr><td nowrap="nowrap" align="center"><input type="hidden" name="domains" value="clisp.cons.org;clisp.podval.org;www.lisp.org" /><label for="sbi" style="display: none">Enter your search terms</label><input type="text" name="q" size="50" maxlength="255" id="sbi" value="24.3. Function REQUIRE" /><label for="sbb" style="display: none">Submit search form</label><input type="submit" name="sa" value="Google Search" id="sbb" /></td></tr><tr><td nowrap="nowrap" align="center"><input type="radio" name="sitesearch" value="" checked="1" id="ss0" /><label for="ss0" title="Search the Web"><small>Web</small></label><input type="radio" name="sitesearch" value="clisp.cons.org" id="ss1" /><label for="ss1" title="Search clisp.cons.org"><small>clisp.cons.org</small></label><input type="radio" name="sitesearch" value="clisp.podval.org" id="ss2" /><label for="ss2" title="Search clisp.podval.org"><small>clisp.podval.org</small></label><input type="radio" name="sitesearch" value="www.lisp.org" id="ss3" /><label for="ss3" title="Search www.lisp.org"><small>www.lisp.org</small></label><input type="hidden" name="client" value="pub-4445255502750357" /><input type="hidden" name="forid" value="1" /><input type="hidden" name="ie" value="UTF-8" /><input type="hidden" name="oe" value="UTF-8" /><input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:000000;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;LH:48;LW:48;L:http://clisp.cons.org/clisp.png;S:http://clisp.cons.org;FORID:1" /><input type="hidden" name="hl" value="en" /></td></tr></table></form><hr /><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="compile-file-path.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="system.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="loadfile.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">24.2. Function <code class="function">COMPILE-FILE-PATHNAME</code> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 24.4. Function <code class="function">LOAD</code></td></tr></table></div></body></html>