89 lines
8.1 KiB
HTML
89 lines
8.1 KiB
HTML
<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>CLHS: Function PROVIDE, REQUIRE</TITLE>
|
|
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
|
|
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
|
|
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
|
|
<LINK REL=TOP HREF="../Front/index.htm">
|
|
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
|
|
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
|
|
<LINK REL=PREV HREF="v_module.htm">
|
|
<LINK REL=UP HREF="c_system.htm">
|
|
<LINK REL=NEXT HREF="25_.htm">
|
|
</HEAD>
|
|
<BODY>
|
|
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="v_module.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="c_system.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="25_.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
<A NAME="provide"><A NAME="require"><I>Function</I> <B>PROVIDE, REQUIRE</B></A></A> <P>
|
|
<P>
|
|
<P><B>Syntax:</B><P>
|
|
<P>
|
|
|
|
<B>provide</B> <I>module-name</I> => <I><A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent"><I>implementation-dependent</I></A></I><P>
|
|
|
|
<B>require</B> <I>module-name <TT>&optional</TT> pathname-list</I> => <I><A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent"><I>implementation-dependent</I></A></I><P>
|
|
<P>
|
|
<P><B>Arguments and Values:</B><P>
|
|
<P>
|
|
<I>module-name</I>---a <A REL=DEFINITION HREF="26_glo_s.htm#string_designator"><I>string designator</I></A>. <P>
|
|
<I>pathname-list</I>---<A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>, or a <A REL=DEFINITION HREF="26_glo_d.htm#designator"><I>designator</I></A> for a <A REL=DEFINITION HREF="26_glo_n.htm#non-empty"><I>non-empty</I></A> <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A> of <A REL=DEFINITION HREF="26_glo_p.htm#pathname_designator"><I>pathname designators</I></A>. The default is <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>. <P>
|
|
<P><B>Description:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="#provide"><B>provide</B></A> adds the <I>module-name</I> to the <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A> held by <A REL=DEFINITION HREF="v_module.htm#STmodulesST"><B>*modules*</B></A>, if such a name is not already present. <P>
|
|
<A REL=DEFINITION HREF="#require"><B>require</B></A> tests for the presence of the <I>module-name</I> in the <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A> held by <A REL=DEFINITION HREF="v_module.htm#STmodulesST"><B>*modules*</B></A>. If it is present, <A REL=DEFINITION HREF="#require"><B>require</B></A> immediately returns. Otherwise, an attempt is made to load an appropriate set of <A REL=DEFINITION HREF="26_glo_f.htm#file"><I>files</I></A> as follows: The <I>pathname-list</I> argument, if <A REL=DEFINITION HREF="26_glo_n.htm#non-nil"><I>non-nil</I></A>, specifies a list of <A REL=DEFINITION HREF="26_glo_p.htm#pathname"><I>pathnames</I></A> to be loaded in order, from left to right. If the <I>pathname-list</I> is <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>, an <A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent"><I>implementation-dependent</I></A> mechanism will be invoked in an attempt to load the module named <I>module-name</I>; if no such module can be loaded, an error of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="e_error.htm#error"><B>error</B></A> is signaled. <P>
|
|
Both functions use <A REL=DEFINITION HREF="f_stgeq_.htm#stringEQ"><B>string=</B></A> to test for the presence of a <I>module-name</I>. <P>
|
|
<P><B>Examples:</B><P>
|
|
<P>
|
|
<P>
|
|
<PRE>
|
|
;;; This illustrates a nonportable use of REQUIRE, because it
|
|
;;; depends on the implementation-dependent file-loading mechanism.
|
|
|
|
(require "CALCULUS")
|
|
|
|
;;; This use of REQUIRE is nonportable because of the literal
|
|
;;; physical pathname.
|
|
|
|
(require "CALCULUS" "/usr/lib/lisp/calculus")
|
|
|
|
;;; One form of portable usage involves supplying a logical pathname,
|
|
;;; with appropriate translations defined elsewhere.
|
|
|
|
(require "CALCULUS" "lib:calculus")
|
|
|
|
;;; Another form of portable usage involves using a variable or
|
|
;;; table lookup function to determine the pathname, which again
|
|
;;; must be initialized elsewhere.
|
|
|
|
(require "CALCULUS" *calculus-module-pathname*)
|
|
</PRE>
|
|
</TT> <P>
|
|
<P><B>Side Effects:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="#provide"><B>provide</B></A> modifies <A REL=DEFINITION HREF="v_module.htm#STmodulesST"><B>*modules*</B></A>. <P>
|
|
<P><B>Affected By:</B><P>
|
|
<P>
|
|
The specific action taken by <A REL=DEFINITION HREF="#require"><B>require</B></A> is affected by calls to <A REL=DEFINITION HREF="#provide"><B>provide</B></A> (or, in general, any changes to the <A REL=DEFINITION HREF="26_glo_v.htm#value"><I>value</I></A> of <A REL=DEFINITION HREF="v_module.htm#STmodulesST"><B>*modules*</B></A>). <P>
|
|
<P><B>Exceptional Situations:</B><P>
|
|
<P>
|
|
Should signal an error of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="e_tp_err.htm#type-error"><B>type-error</B></A> if <I>module-name</I> is not a <A REL=DEFINITION HREF="26_glo_s.htm#string_designator"><I>string designator</I></A>. <P>
|
|
If <A REL=DEFINITION HREF="#require"><B>require</B></A> fails to perform the requested operation due to a problem while interacting with the <A REL=DEFINITION HREF="26_glo_f.htm#file_system"><I>file system</I></A>, an error of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="e_file_e.htm#file-error"><B>file-error</B></A> is signaled. <P>
|
|
An error of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="e_file_e.htm#file-error"><B>file-error</B></A> might be signaled if any <A REL=DEFINITION HREF="26_glo_p.htm#pathname"><I>pathname</I></A> in <I>pathname-list</I> is a <A REL=DEFINITION HREF="26_glo_d.htm#designator"><I>designator</I></A> for a <A REL=DEFINITION HREF="26_glo_w.htm#wild"><I>wild</I></A> <A REL=DEFINITION HREF="26_glo_p.htm#pathname"><I>pathname</I></A>. <P>
|
|
<P><B>See Also:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="v_module.htm#STmodulesST"><B>*modules*</B></A>, <A REL=CHILD HREF="19_ab.htm">Section 19.1.2 (Pathnames as Filenames)</A> <P>
|
|
<P><B>Notes:</B><P>
|
|
<P>
|
|
The functions <A REL=DEFINITION HREF="#provide"><B>provide</B></A> and <A REL=DEFINITION HREF="#require"><B>require</B></A> are deprecated. <P>
|
|
If a module consists of a single <A REL=DEFINITION HREF="26_glo_p.htm#package"><I>package</I></A>, it is customary for the package and module names to be the same. <P>
|
|
<P>
|
|
<P><HR>The following <A REL=META HREF="../Front/X3J13Iss.htm">X3J13 cleanup issues</A>, <I>not part of the specification</I>, apply to this section:<P><UL><LI> <A REL=CHILD HREF="../Issues/iss157.htm">FILE-OPEN-ERROR:SIGNAL-FILE-ERROR</A><LI> <A REL=CHILD HREF="../Issues/iss295.htm">REQUIRE-PATHNAME-DEFAULTS-YET-AGAIN:RESTORE-ARGUMENT</A><LI> <A REL=CHILD HREF="../Issues/iss294.htm">REQUIRE-PATHNAME-DEFAULTS-AGAIN:X3J13-DEC-91</A><P></UL><HR>
|
|
|
|
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
|
|
|
|
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
|
|
</BODY>
|
|
</HTML>
|