1
0
Fork 0
cl-sites/novaspec.org/cl/f_import.html

469 lines
9.5 KiB
HTML
Raw Normal View History

2025-02-05 18:52:26 +01:00
<!DOCTYPE HTML>
<HTML LANG="en-us"
><HEAD
><TITLE
>import | Common Lisp Nova Spec</TITLE
><META CHARSET="US-ASCII"
><LINK REL="canonical" HREF="f_import.html"
><LINK REL="next" HREF="f_list-all-packages.html" TYPE="text/html" TITLE="list-all-packages"
><LINK REL="prev" HREF="f_find-all-symbols.html" TYPE="text/html" TITLE="find-all-symbols"
><LINK REL="up" HREF="11_2_Packages_Dictionary.html" TYPE="text/html" TITLE="11.2 Packages 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="11_Packages.html"
>11. Packages</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="11_2_Packages_Dictionary.html"
>11.2 Packages Dictionary</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="f_import.html"
>import</A
></SPAN
></DIV
><DIV CLASS="apropos"
><DIV CLASS="apropos-io"
><A HREF="f_find-all-symbols.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_list-all-packages.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="import"
></SPAN
><B
>import</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
><P CLASS="j"
><B
>import</B
> <SPAN CLASS="cmssi"
>symbols</SPAN
> <SPAN CLASS="cmtt"
>&amp;optional</SPAN
> <SPAN CLASS="cmssi"
>package</SPAN
> <SPAN CLASS="arrow"
>&#8594;</SPAN
> <SPAN CLASS="misc"
><B
>t</B
></SPAN
></P
></DD
><DT
><B
>Arguments and Values</B
></DT
><DD
><P CLASS="j"
><VAR CLASS="param"
>symbols</VAR
> &#8212; a <A HREF="26_1_Glossary.html#designator"
><EM CLASS="term"
>designator</EM
></A
> for a <A HREF="26_1_Glossary.html#list"
><EM CLASS="term"
>list</EM
></A
> of <A HREF="26_1_Glossary.html#symbol"
><EM CLASS="term"
>symbols</EM
></A
>. </P
><P CLASS="j"
><VAR CLASS="param"
>package</VAR
> &#8212; a <A HREF="26_1_Glossary.html#package_designator"
><EM CLASS="term"
>package designator</EM
></A
>. The default is the <A HREF="26_1_Glossary.html#current_package"
><EM CLASS="term"
>current package</EM
></A
>.</P
></DD
><DT
><B
>Description</B
></DT
><DD
><P CLASS="j"
><A HREF="f_import.html" CLASS="funref"
><B
>import</B
></A
> adds <VAR CLASS="param"
>symbol</VAR
> or <VAR CLASS="param"
>symbols</VAR
> to the internals of <VAR CLASS="param"
>package</VAR
>, checking for name conflicts with existing <A HREF="26_1_Glossary.html#symbol"
><EM CLASS="term"
>symbols</EM
></A
> either <A HREF="26_1_Glossary.html#present"
><EM CLASS="term"
>present</EM
></A
> in <VAR CLASS="param"
>package</VAR
> or <A HREF="26_1_Glossary.html#accessible"
><EM CLASS="term"
>accessible</EM
></A
> to it. Once the <VAR CLASS="param"
>symbols</VAR
> have been <A HREF="26_1_Glossary.html#import"
><EM CLASS="term"
>imported</EM
></A
>, they may be referenced in the <A HREF="26_1_Glossary.html#import"
><EM CLASS="term"
>importing</EM
></A
> <VAR CLASS="param"
>package</VAR
> without the use of a <A HREF="26_1_Glossary.html#package_prefix"
><EM CLASS="term"
>package prefix</EM
></A
> when using the <A HREF="26_1_Glossary.html#Lisp_reader"
><EM CLASS="term"
>Lisp reader</EM
></A
>. </P
><P CLASS="j"
>A name conflict in <A HREF="f_import.html" CLASS="funref"
><B
>import</B
></A
> between the <VAR CLASS="param"
>symbol</VAR
> being imported and a symbol inherited from some other <A HREF="26_1_Glossary.html#package"
><EM CLASS="term"
>package</EM
></A
> can be resolved in favor of the <VAR CLASS="param"
>symbol</VAR
> being <A HREF="26_1_Glossary.html#import"
><EM CLASS="term"
>imported</EM
></A
> by making it a shadowing symbol, or in favor of the <A HREF="26_1_Glossary.html#symbol"
><EM CLASS="term"
>symbol</EM
></A
> already <A HREF="26_1_Glossary.html#accessible"
><EM CLASS="term"
>accessible</EM
></A
> by not doing the <A HREF="f_import.html" CLASS="funref"
><B
>import</B
></A
>. A name conflict in <A HREF="f_import.html" CLASS="funref"
><B
>import</B
></A
> with a <A HREF="26_1_Glossary.html#symbol"
><EM CLASS="term"
>symbol</EM
></A
> already <A HREF="26_1_Glossary.html#present"
><EM CLASS="term"
>present</EM
></A
> in the <VAR CLASS="param"
>package</VAR
> may be resolved by uninterning that <A HREF="26_1_Glossary.html#symbol"
><EM CLASS="term"
>symbol</EM
></A
>, or by not doing the <A HREF="f_import.html" CLASS="funref"
><B
>import</B
></A
>. </P
><P CLASS="j"
>The imported <A HREF="26_1_Glossary.html#symbol"
><EM CLASS="term"
>symbol</EM
></A
> is not automatically exported from the <A HREF="26_1_Glossary.html#current_package"
><EM CLASS="term"
>current package</EM
></A
>, but if it is already <A HREF="26_1_Glossary.html#present"
><EM CLASS="term"
>present</EM
></A
> and external, then the fact that it is external is not changed. If any <A HREF="26_1_Glossary.html#symbol"
><EM CLASS="term"
>symbol</EM
></A
> to be <A HREF="26_1_Glossary.html#import"
><EM CLASS="term"
>imported</EM
></A
> has no home package (<I CLASS="i"
><I
>i.e.</I
></I
>, <SPAN CLASS="cmtt"
>(symbol-package</SPAN
> <VAR CLASS="param"
>symbol</VAR
><SPAN CLASS="cmtt"
>)</SPAN
> <SPAN CLASS="arrow"
>&#8594;</SPAN
> <SPAN CLASS="cmtt"
>nil</SPAN
>), <A HREF="f_import.html" CLASS="funref"
><B
>import</B
></A
> sets the <A HREF="26_1_Glossary.html#home_package"
><EM CLASS="term"
>home package</EM
></A
> of the <VAR CLASS="param"
>symbol</VAR
> to <VAR CLASS="param"
>package</VAR
>. </P
><P CLASS="j"
>If the <VAR CLASS="param"
>symbol</VAR
> is already <A HREF="26_1_Glossary.html#present"
><EM CLASS="term"
>present</EM
></A
> in the importing <VAR CLASS="param"
>package</VAR
>, <A HREF="f_import.html" CLASS="funref"
><B
>import</B
></A
> has no effect.</P
></DD
><DT
><B
>Examples</B
></DT
><DD
><PRE CLASS="screen"
>(import 'common-lisp::car (make-package 'temp :use nil)) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> T
(find-symbol "CAR" 'temp) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> CAR, :INTERNAL
(find-symbol "CDR" 'temp) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> NIL, NIL</PRE
><P CLASS="j"
>The form <CODE CLASS="f"
>(import 'editor:buffer)</CODE
> takes the external symbol named <CODE CLASS="f"
>buffer</CODE
> in the <SPAN CLASS="packref"
><SPAN CLASS="cmtt"
>EDITOR</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#package"
><EM CLASS="term"
>package</EM
></A
> (this symbol was located when the form was read by the <A HREF="26_1_Glossary.html#Lisp_reader"
><EM CLASS="term"
>Lisp reader</EM
></A
>) and adds it to the <A HREF="26_1_Glossary.html#current_package"
><EM CLASS="term"
>current package</EM
></A
> as an <A HREF="26_1_Glossary.html#internal_symbol"
><EM CLASS="term"
>internal symbol</EM
></A
>. The symbol <CODE CLASS="f"
>buffer</CODE
> is then <A HREF="26_1_Glossary.html#present"
><EM CLASS="term"
>present</EM
></A
> in the <A HREF="26_1_Glossary.html#current_package"
><EM CLASS="term"
>current package</EM
></A
>.</P
></DD
><DT
><B
>Side Effects</B
></DT
><DD
><P CLASS="j"
>The package system is modified.</P
></DD
><DT
><B
>Affected By</B
></DT
><DD
><P CLASS="j"
>Current state of the package system.</P
></DD
><DT
><B
>Exceptional Situations</B
></DT
><DD
><P CLASS="j"
><A HREF="f_import.html" CLASS="funref"
><B
>import</B
></A
> signals a <A HREF="26_1_Glossary.html#correctable"
><EM CLASS="term"
>correctable</EM
></A
> error of <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
> <A HREF="t_package-error.html" CLASS="typeref"
><B
>package-error</B
></A
> if any of the <VAR CLASS="param"
>symbols</VAR
> to be <A HREF="26_1_Glossary.html#import"
><EM CLASS="term"
>imported</EM
></A
> has the <A HREF="26_1_Glossary.html#same"
><EM CLASS="term"
>same</EM
></A
> <A HREF="26_1_Glossary.html#name"
><EM CLASS="term"
>name</EM
></A
> (under <A HREF="f_string_eq.html" CLASS="funref"
><B
>string=</B
></A
>) as some distinct <A HREF="26_1_Glossary.html#symbol"
><EM CLASS="term"
>symbol</EM
></A
> (under <A HREF="f_eql.html" CLASS="funref"
><B
>eql</B
></A
>) already <A HREF="26_1_Glossary.html#accessible"
><EM CLASS="term"
>accessible</EM
></A
> in the <VAR CLASS="param"
>package</VAR
>, even if the conflict is with a <A HREF="26_1_Glossary.html#shadowing_symbol"
><EM CLASS="term"
>shadowing symbol</EM
></A
> of the <VAR CLASS="param"
>package</VAR
>.</P
></DD
><DT
><B
>See Also</B
></DT
><DD
><P CLASS="j"
><A HREF="f_shadow.html" CLASS="funref"
><B
>shadow</B
></A
>, <A HREF="f_export.html" CLASS="funref"
><B
>export</B
></A
></P
></DD
></DL
></DIV
></DIV
><DIV CLASS="footer"
><DIV CLASS="btmnav"
><A HREF="f_find-all-symbols.html" CLASS="prev"
>&#8592;</A
><A HREF="f_list-all-packages.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
>