1
0
Fork 0
cl-sites/novaspec.org/cl/f_compile-file.html
2025-02-05 18:52:26 +01:00

844 lines
No EOL
18 KiB
HTML

<!DOCTYPE HTML>
<HTML LANG="en-us"
><HEAD
><TITLE
>compile-file | Common Lisp Nova Spec</TITLE
><META CHARSET="US-ASCII"
><LINK REL="canonical" HREF="f_compile-file.html"
><LINK REL="next" HREF="f_compile-file-pathname.html" TYPE="text/html" TITLE="compile-file-pathname"
><LINK REL="prev" HREF="24_2_System_Construction_Dictionary.html" TYPE="text/html" TITLE="24.2 System Construction Dictionary"
><LINK REL="up" HREF="24_2_System_Construction_Dictionary.html" TYPE="text/html" TITLE="24.2 System Construction Dictionary"
><LINK REL="start" HREF="index.html" TYPE="text/html" TITLE="Common Lisp Nova Spec"
><META NAME="VIEWPORT" CONTENT="width=device-width, initial-scale=1.0"
><LINK REL="STYLESHEET" HREF="dpans.css%3F3909942064.css"
><SCRIPT SRC="dpans.js%3F3909942064"
></SCRIPT
><SCRIPT SRC="apropos.js%3F3909942064"
></SCRIPT
></HEAD
><BODY
><DIV
><DIV CLASS="topnav"
><DIV CLASS="breadcrumb"
><SPAN CLASS="breadcrumb-item"
><A HREF="index.html"
>Common Lisp Nova Spec</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="24_System_Construction.html"
>24. System Construction</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="24_2_System_Construction_Dictionary.html"
>24.2 System Construction Dictionary</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="f_compile-file.html"
>compile-file</A
></SPAN
></DIV
><DIV CLASS="apropos"
><DIV CLASS="apropos-io"
><A HREF="24_2_System_Construction_Dictionary.html" CLASS="prev"
>&#8592;</A
><SPAN ID="apropos-label"
>Apropos </SPAN
><INPUT ID="apropos" AUTOFOCUS="AUTOFOCUS" PLACEHOLDER="Type here to search" ONINPUT="aproposInput(this);" ONKEYUP="aproposKeyup(event);" ONCHANGE="aproposChange(this);" ONFOCUS="aproposFocus(this);" ONFOCUSOUT="aproposFocusout(this);"
><A HREF="f_compile-file-pathname.html" CLASS="next"
>&#8594;</A
></DIV
><DIV ID="apropos-res"
></DIV
></DIV
></DIV
><DIV CLASS="matter"
><DIV CLASS="com"
><DIV CLASS="begincom"
><HR
><TABLE WIDTH="100%" CELLSPACING="0" CELLPADDING="0"
><TR
><TD ALIGN="LEFT" VALIGN="BASELINE" WIDTH="100%" CLASS="name"
><SPAN CLASS="idx" DATA-KIND="idxref" DATA-TERM="compile-file"
></SPAN
><B
>compile-file</B
></TD
><TD ALIGN="RIGHT" VALIGN="BASELINE" WIDTH="0" NOWRAP="NOWRAP" CLASS="ftype"
><I
>Function</I
></TD
></TR
></TABLE
><HR
></DIV
><UL CLASS="subtoc"
></UL
><DL
><DT
><B
>Syntax</B
></DT
><DD
><TABLE CELLPADDING="0" CELLSPACING="0"
><TR
><TD VALIGN="BASELINE" ALIGN="LEFT" NOWRAP="NOWRAP"
><B
>compile-file</B
><SPAN CLASS="cmssi"
>&#160;</SPAN
><SPAN CLASS="cmssi"
>input-file</SPAN
><SPAN CLASS="cmtt"
>&#160;</SPAN
><SPAN CLASS="cmtt"
>&amp;key</SPAN
><SPAN CLASS="cmssi"
>&#160;</SPAN
></TD
><TD VALIGN="BASELINE" ALIGN="LEFT"
><SPAN CLASS="cmssi"
>output-file</SPAN
> <SPAN CLASS="cmssi"
>verbose</SPAN
><BR
><SPAN CLASS="cmssi"
>print</SPAN
> <SPAN CLASS="cmssi"
>external-format</SPAN
></TD
></TR
></TABLE
><DIV
><SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <SPAN CLASS="cmssi"
>output-truename,</SPAN
> <SPAN CLASS="cmssi"
>warnings-p,</SPAN
> <SPAN CLASS="cmssi"
>failure-p</SPAN
></DIV
></DD
><DT
><B
>Arguments and Values</B
></DT
><DD
><P CLASS="j"
><VAR CLASS="param"
>input-file</VAR
> &#8212; a <A HREF="26_1_Glossary.html#pathname_designator"
><EM CLASS="term"
>pathname designator</EM
></A
>. (Default fillers for unspecified components are taken from <A HREF="v_default-pathname-defaults.html" CLASS="varref"
><B
>*default-pathname-defaults*</B
></A
>.) </P
><P CLASS="j"
><VAR CLASS="param"
>output-file</VAR
> &#8212; a <A HREF="26_1_Glossary.html#pathname_designator"
><EM CLASS="term"
>pathname designator</EM
></A
>. The default is <A HREF="26_1_Glossary.html#implementation-defined"
><EM CLASS="term"
>implementation-defined</EM
></A
>. </P
><P CLASS="j"
><VAR CLASS="param"
>verbose</VAR
> &#8212; a <A HREF="26_1_Glossary.html#generalized_boolean"
><EM CLASS="term"
>generalized boolean</EM
></A
>. The default is the <A HREF="26_1_Glossary.html#value"
><EM CLASS="term"
>value</EM
></A
> of <A HREF="v_compile-print.html" CLASS="misc"
><B
>*compile-verbose*</B
></A
>. </P
><P CLASS="j"
><VAR CLASS="param"
>print</VAR
> &#8212; a <A HREF="26_1_Glossary.html#generalized_boolean"
><EM CLASS="term"
>generalized boolean</EM
></A
>. The default is the <A HREF="26_1_Glossary.html#value"
><EM CLASS="term"
>value</EM
></A
> of <A HREF="v_compile-print.html" CLASS="misc"
><B
>*compile-print*</B
></A
>. </P
><P CLASS="j"
><VAR CLASS="param"
>external-format</VAR
> &#8212; an <A HREF="26_1_Glossary.html#external_file_format_designator"
><EM CLASS="term"
>external file format designator</EM
></A
>. The default is <SPAN CLASS="kwd"
><SPAN CLASS="cmtt"
>:default</SPAN
></SPAN
>. </P
><P CLASS="j"
><VAR CLASS="param"
>output-truename</VAR
> &#8212; a <A HREF="26_1_Glossary.html#pathname"
><EM CLASS="term"
>pathname</EM
></A
> (the <A HREF="f_truename.html" CLASS="funref"
><B
>truename</B
></A
> of the output <A HREF="26_1_Glossary.html#file"
><EM CLASS="term"
>file</EM
></A
>), or <SPAN CLASS="misc"
><B
>nil</B
></SPAN
>. </P
><P CLASS="j"
><VAR CLASS="param"
>warnings-p</VAR
> &#8212; a <A HREF="26_1_Glossary.html#generalized_boolean"
><EM CLASS="term"
>generalized boolean</EM
></A
>. </P
><P CLASS="j"
><VAR CLASS="param"
>failure-p</VAR
> &#8212; a <A HREF="26_1_Glossary.html#generalized_boolean"
><EM CLASS="term"
>generalized boolean</EM
></A
>.</P
></DD
><DT
><B
>Description</B
></DT
><DD
><P CLASS="j"
><A HREF="f_compile-file.html" CLASS="funref"
><B
>compile-file</B
></A
> transforms the contents of the file specified by <VAR CLASS="param"
>input-file</VAR
> into <A HREF="26_1_Glossary.html#implementation-dependent"
><EM CLASS="term"
>implementation-dependent</EM
></A
> binary data which are placed in the file specified by <VAR CLASS="param"
>output-file</VAR
>. </P
><P CLASS="j"
>The <A HREF="26_1_Glossary.html#file"
><EM CLASS="term"
>file</EM
></A
> to which <VAR CLASS="param"
>input-file</VAR
> refers should be a <A HREF="26_1_Glossary.html#source_file"
><EM CLASS="term"
>source file</EM
></A
>. <VAR CLASS="param"
>output-file</VAR
> can be used to specify an output <A HREF="26_1_Glossary.html#pathname"
><EM CLASS="term"
>pathname</EM
></A
>; the actual <A HREF="26_1_Glossary.html#pathname"
><EM CLASS="term"
>pathname</EM
></A
> of the <A HREF="26_1_Glossary.html#compiled_file"
><EM CLASS="term"
>compiled file</EM
></A
> to which <A HREF="26_1_Glossary.html#compiled_code"
><EM CLASS="term"
>compiled code</EM
></A
> will be output is computed as if by calling <A HREF="f_compile-file-pathname.html" CLASS="funref"
><B
>compile-file-pathname</B
></A
>. </P
><P CLASS="j"
>If <VAR CLASS="param"
>input-file</VAR
> or <VAR CLASS="param"
>output-file</VAR
> is a <A HREF="26_1_Glossary.html#logical_pathname"
><EM CLASS="term"
>logical pathname</EM
></A
>, it is translated into a <A HREF="26_1_Glossary.html#physical_pathname"
><EM CLASS="term"
>physical pathname</EM
></A
> as if by calling <A HREF="f_translate-logical-pathname.html" CLASS="funref"
><B
>translate-logical-pathname</B
></A
>. </P
><P CLASS="j"
>If <VAR CLASS="param"
>verbose</VAR
> is <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>, <A HREF="f_compile-file.html" CLASS="funref"
><B
>compile-file</B
></A
> prints a message in the form of a comment (<I CLASS="i"
><I
>i.e.</I
></I
>, with a leading <A HREF="26_1_Glossary.html#semicolon"
><EM CLASS="term"
>semicolon</EM
></A
>) to <A HREF="26_1_Glossary.html#standard_output"
><EM CLASS="term"
>standard output</EM
></A
> indicating what <A HREF="26_1_Glossary.html#file"
><EM CLASS="term"
>file</EM
></A
> is being <A HREF="26_1_Glossary.html#compile"
><EM CLASS="term"
>compiled</EM
></A
> and other useful information. If <VAR CLASS="param"
>verbose</VAR
> is <A HREF="26_1_Glossary.html#false"
><EM CLASS="term"
>false</EM
></A
>, <A HREF="f_compile-file.html" CLASS="funref"
><B
>compile-file</B
></A
> does not print this information. </P
><P CLASS="j"
>If <VAR CLASS="param"
>print</VAR
> is <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>, information about <A HREF="26_1_Glossary.html#top_level_form"
><EM CLASS="term"
>top level forms</EM
></A
> in the file being compiled is printed to <A HREF="26_1_Glossary.html#standard_output"
><EM CLASS="term"
>standard output</EM
></A
>. Exactly what is printed is <A HREF="26_1_Glossary.html#implementation-dependent"
><EM CLASS="term"
>implementation-dependent</EM
></A
>, but nevertheless some information is printed. If <VAR CLASS="param"
>print</VAR
> is <SPAN CLASS="misc"
><B
>nil</B
></SPAN
>, no information is printed. </P
><P CLASS="j"
>The <VAR CLASS="param"
>external-format</VAR
> specifies the <A HREF="26_1_Glossary.html#external_file_format"
><EM CLASS="term"
>external file format</EM
></A
> to be used when opening the <A HREF="26_1_Glossary.html#file"
><EM CLASS="term"
>file</EM
></A
>; see the <A HREF="26_1_Glossary.html#function"
><EM CLASS="term"
>function</EM
></A
> <A HREF="f_open.html" CLASS="funref"
><B
>open</B
></A
>. <A HREF="f_compile-file.html" CLASS="funref"
><B
>compile-file</B
></A
> and <A HREF="f_load.html" CLASS="funref"
><B
>load</B
></A
> must cooperate in such a way that the resulting <A HREF="26_1_Glossary.html#compiled_file"
><EM CLASS="term"
>compiled file</EM
></A
> can be <A HREF="26_1_Glossary.html#load"
><EM CLASS="term"
>loaded</EM
></A
> without specifying an <A HREF="26_1_Glossary.html#external_file_format"
><EM CLASS="term"
>external file format</EM
></A
> anew; see the <A HREF="26_1_Glossary.html#function"
><EM CLASS="term"
>function</EM
></A
> <A HREF="f_load.html" CLASS="funref"
><B
>load</B
></A
>. </P
><P CLASS="j"
><A HREF="f_compile-file.html" CLASS="funref"
><B
>compile-file</B
></A
> binds <A HREF="v_readtable.html" CLASS="varref"
><B
>*readtable*</B
></A
> and <A HREF="v_package.html" CLASS="varref"
><B
>*package*</B
></A
> to the values they held before processing the file. </P
><P CLASS="j"
><A HREF="v_compile-file-pathname.html" CLASS="varref"
><B
>*compile-file-truename*</B
></A
> is bound by <A HREF="f_compile-file.html" CLASS="funref"
><B
>compile-file</B
></A
> to hold the <A HREF="26_1_Glossary.html#truename"
><EM CLASS="term"
>truename</EM
></A
> of the <A HREF="26_1_Glossary.html#pathname"
><EM CLASS="term"
>pathname</EM
></A
> of the file being compiled. </P
><P CLASS="j"
><A HREF="v_compile-file-pathname.html" CLASS="varref"
><B
>*compile-file-pathname*</B
></A
> is bound by <A HREF="f_compile-file.html" CLASS="funref"
><B
>compile-file</B
></A
> to hold a <A HREF="26_1_Glossary.html#pathname"
><EM CLASS="term"
>pathname</EM
></A
> denoted by the first argument to <A HREF="f_compile-file.html" CLASS="funref"
><B
>compile-file</B
></A
>, merged against the defaults; that is, <CODE CLASS="f"
>(pathname (merge-pathnames <VAR CLASS="param"
>input-file</VAR
>))</CODE
>. </P
><P CLASS="j"
>The compiled <A HREF="26_1_Glossary.html#function"
><EM CLASS="term"
>functions</EM
></A
> contained in the <A HREF="26_1_Glossary.html#compiled_file"
><EM CLASS="term"
>compiled file</EM
></A
> become available for use when the <A HREF="26_1_Glossary.html#compiled_file"
><EM CLASS="term"
>compiled file</EM
></A
> is <A HREF="26_1_Glossary.html#load"
><EM CLASS="term"
>loaded</EM
></A
> into Lisp. Any function definition that is processed by the compiler, including <CODE CLASS="f"
>#'(lambda ...)</CODE
> forms and local function definitions made by <A HREF="f_flet.html" CLASS="specref"
><B
>flet</B
></A
>, <A HREF="f_flet.html" CLASS="specref"
><B
>labels</B
></A
> and <A HREF="f_defun.html" CLASS="macref"
><B
>defun</B
></A
> forms, result in an <A HREF="26_1_Glossary.html#object"
><EM CLASS="term"
>object</EM
></A
> of <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
> <A HREF="t_compiled-function.html" CLASS="typeref"
><B
>compiled-function</B
></A
>. </P
><P CLASS="j"
>The <A HREF="26_1_Glossary.html#primary_value"
><EM CLASS="term"
>primary value</EM
></A
> returned by <A HREF="f_compile-file.html" CLASS="funref"
><B
>compile-file</B
></A
>, <VAR CLASS="param"
>output-truename</VAR
>, is the <A HREF="f_truename.html" CLASS="funref"
><B
>truename</B
></A
> of the output file, or <SPAN CLASS="misc"
><B
>nil</B
></SPAN
> if the file could not be created. </P
><P CLASS="j"
>The <A HREF="26_1_Glossary.html#secondary_value"
><EM CLASS="term"
>secondary value</EM
></A
>, <VAR CLASS="param"
>warnings-p</VAR
>, is <A HREF="26_1_Glossary.html#false"
><EM CLASS="term"
>false</EM
></A
> if no <A HREF="26_1_Glossary.html#condition"
><EM CLASS="term"
>conditions</EM
></A
> of <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
> <A HREF="t_error.html" CLASS="typeref"
><B
>error</B
></A
> or <A HREF="t_warning.html" CLASS="typeref"
><B
>warning</B
></A
> were detected by the compiler, and <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
> otherwise. </P
><P CLASS="j"
>The <A HREF="26_1_Glossary.html#tertiary_value"
><EM CLASS="term"
>tertiary value</EM
></A
>, <VAR CLASS="param"
>failure-p</VAR
>, is <A HREF="26_1_Glossary.html#false"
><EM CLASS="term"
>false</EM
></A
> if no <A HREF="26_1_Glossary.html#condition"
><EM CLASS="term"
>conditions</EM
></A
> of <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
> <A HREF="t_error.html" CLASS="typeref"
><B
>error</B
></A
> or <A HREF="t_warning.html" CLASS="typeref"
><B
>warning</B
></A
> (other than <A HREF="t_style-warning.html" CLASS="typeref"
><B
>style-warning</B
></A
>) were detected by the compiler, and <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
> otherwise. </P
><P CLASS="j"
>For general information about how <A HREF="26_1_Glossary.html#file"
><EM CLASS="term"
>files</EM
></A
> are processed by the <A HREF="26_1_Glossary.html#file_compiler"
><EM CLASS="term"
>file compiler</EM
></A
>, see <A HREF="3_2_Compilation.html#sec_3_2_3" CLASS="secref"
><SPAN CLASS="cmr"
>Section</SPAN
> <SPAN CLASS="cmr"
>3.2.3</SPAN
> <SPAN CLASS="cmr"
>(File</SPAN
> <SPAN CLASS="cmr"
>Compilation)</SPAN
></A
>. </P
><P CLASS="j"
><A HREF="26_1_Glossary.html#program"
><EM CLASS="term"
>Programs</EM
></A
> to be compiled by the <A HREF="26_1_Glossary.html#file_compiler"
><EM CLASS="term"
>file compiler</EM
></A
> must only contain <A HREF="26_1_Glossary.html#externalizable_object"
><EM CLASS="term"
>externalizable objects</EM
></A
>; for details on such <A HREF="26_1_Glossary.html#object"
><EM CLASS="term"
>objects</EM
></A
>, see <A HREF="3_2_Compilation.html#sec_3_2_4" CLASS="secref"
><SPAN CLASS="cmr"
>Section</SPAN
> <SPAN CLASS="cmr"
>3.2.4</SPAN
> <SPAN CLASS="cmr"
>(Literal</SPAN
> <SPAN CLASS="cmr"
>Objects</SPAN
> <SPAN CLASS="cmr"
>in</SPAN
> <SPAN CLASS="cmr"
>Compiled</SPAN
> <SPAN CLASS="cmr"
>Files)</SPAN
></A
>. For information on how to extend the set of <A HREF="26_1_Glossary.html#externalizable_object"
><EM CLASS="term"
>externalizable objects</EM
></A
>, see the <A HREF="26_1_Glossary.html#function"
><EM CLASS="term"
>function</EM
></A
> <A HREF="f_make-load-form.html" CLASS="funref"
><B
>make-load-form</B
></A
> and <A HREF="3_2_Compilation.html#sec_3_2_4_4" CLASS="secref"
><SPAN CLASS="cmr"
>Section</SPAN
> <SPAN CLASS="cmr"
>3.2.4.4</SPAN
> <SPAN CLASS="cmr"
>(Additional</SPAN
> <SPAN CLASS="cmr"
>Constraints</SPAN
> <SPAN CLASS="cmr"
>on</SPAN
> <SPAN CLASS="cmr"
>Externalizable</SPAN
> <SPAN CLASS="cmr"
>Objects)</SPAN
></A
>.</P
></DD
><DT
><B
>Affected By</B
></DT
><DD
><P CLASS="j"
><A HREF="v_debug-io.html" CLASS="varref"
><B
>*error-output*</B
></A
>, <A HREF="v_debug-io.html" CLASS="varref"
><B
>*standard-output*</B
></A
>, <A HREF="v_compile-print.html" CLASS="varref"
><B
>*compile-verbose*</B
></A
>, <A HREF="v_compile-print.html" CLASS="varref"
><B
>*compile-print*</B
></A
> </P
><P CLASS="j"
>The computer&#8217;s file system.</P
></DD
><DT
><B
>Exceptional Situations</B
></DT
><DD
><P CLASS="j"
>For information about errors detected during the compilation process, see <A HREF="3_2_Compilation.html#sec_3_2_5" CLASS="secref"
><SPAN CLASS="cmr"
>Section</SPAN
> <SPAN CLASS="cmr"
>3.2.5</SPAN
> <SPAN CLASS="cmr"
>(Exceptional</SPAN
> <SPAN CLASS="cmr"
>Situations</SPAN
> <SPAN CLASS="cmr"
>in</SPAN
> <SPAN CLASS="cmr"
>the</SPAN
> <SPAN CLASS="cmr"
>Compiler)</SPAN
></A
>. </P
><P CLASS="j"
>An error of <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
> <A HREF="t_file-error.html" CLASS="typeref"
><B
>file-error</B
></A
> might be signaled if <SPAN CLASS="cmtt"
>(wild-pathname-p</SPAN
> <VAR CLASS="param"
>input-file</VAR
><SPAN CLASS="cmtt"
>)</SPAN
> returns true. </P
><P CLASS="j"
>If either the attempt to open the <A HREF="26_1_Glossary.html#source_file"
><EM CLASS="term"
>source file</EM
></A
> for input or the attempt to open the <A HREF="26_1_Glossary.html#compiled_file"
><EM CLASS="term"
>compiled file</EM
></A
> for output fails, an error of <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
> <A HREF="t_file-error.html" CLASS="typeref"
><B
>file-error</B
></A
> is signaled.</P
></DD
><DT
><B
>See Also</B
></DT
><DD
><P CLASS="j"
><A HREF="f_compile.html" CLASS="funref"
><B
>compile</B
></A
>, <A HREF="m_declare.html" CLASS="misc"
><B
>declare</B
></A
>, <A HREF="f_eval-when.html" CLASS="specref"
><B
>eval-when</B
></A
>, <A HREF="t_pathname.html" CLASS="typeref"
><B
>pathname</B
></A
>, <A HREF="t_logical-pathname.html" CLASS="typeref"
><B
>logical-pathname</B
></A
>, <A HREF="20_1_File_System_Concepts.html#sec_20_1" CLASS="secref"
><SPAN CLASS="cmr"
>Section</SPAN
> <SPAN CLASS="cmr"
>20.1</SPAN
> <SPAN CLASS="cmr"
>(File</SPAN
> <SPAN CLASS="cmr"
>System</SPAN
> <SPAN CLASS="cmr"
>Concepts)</SPAN
></A
>, <A HREF="19_1_Overview_of_Filenames.html#sec_19_1_2" CLASS="secref"
><SPAN CLASS="cmr"
>Section</SPAN
> <SPAN CLASS="cmr"
>19.1.2</SPAN
> <SPAN CLASS="cmr"
>(Pathnames</SPAN
> <SPAN CLASS="cmr"
>as</SPAN
> <SPAN CLASS="cmr"
>Filenames)</SPAN
></A
></P
></DD
></DL
></DIV
></DIV
><DIV CLASS="footer"
><DIV CLASS="btmnav"
><A HREF="24_2_System_Construction_Dictionary.html" CLASS="prev"
>&#8592;</A
><A HREF="f_compile-file-pathname.html" CLASS="next"
>&#8594;</A
></DIV
><DIV CLASS="trail"
>Conversion to HTML copyright 2023 by Gilbert Baumann</DIV
></DIV
></DIV
><SCRIPT
>domReady();</SCRIPT
></BODY
></HTML
>