User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cl:functions:use-package [2019/11/11 05:00]
cl:functions:use-package [2019/11/14 16:00] (current)
Line 1: Line 1:
 +====== Function USE-PACKAGE ======
 +
 +====Syntax====
 +  * **use-package** //​packages-to-use//​ ''&​optional''​ //package// → **[[CL:​Constant Variables:​t]]**
 +
 +====Arguments and Values====
 +  * //​packages-to-use//​ - a //​[[CL:​Glossary:​designator]]//​ for a //​[[CL:​Glossary:​list]]//​ of //​[[CL:​Glossary:​package designators]]//​. The **''​keyword''​** [[CL:​Constant Variables:​package]] may not be supplied.
 +  * //package// - a //​[[CL:​Glossary:​package designator]]//​. The default is the //​[[CL:​Glossary:​current package]]//​. The //package// cannot be the **''​keyword''​** //​[[CL:​Glossary:​package]]//​.
 +
 +====Description====
 +**use-package** causes //package// to inherit all the //​[[CL:​Glossary:​external symbols]]// of //​packages-to-use//​. The inherited //​[[CL:​Glossary:​symbol|symbols]]//​ become //​[[CL:​Glossary:​accessible]]//​ as //​[[CL:​Glossary:​internal symbols]]// of //​package//​.
 +
 +//​Packages-to-use//​ are added to the //​[[CL:​Glossary:​use list]]// of //package// if they are not there already. All //​[[CL:​Glossary:​external symbols]]// in //​packages-to-use//​ become //​[[CL:​Glossary:​accessible]]//​ in //package// as //​[[CL:​Glossary:​internal symbols]]//​.
 +
 +**use-package** does not cause any new //​[[CL:​Glossary:​symbol|symbols]]//​ to be //​[[CL:​Glossary:​present]]//​ in //package// but only makes them //​[[CL:​Glossary:​accessible]]//​ by inheritance.
 +
 +**use-package** checks for name conflicts between the newly imported symbols and those already //​[[CL:​Glossary:​accessible]]//​ in //​package//​.
 +
 +A name conflict in **use-package** between two external symbols inherited by //package// from //​packages-to-use//​ may be resolved in favor of either //​[[CL:​Glossary:​symbol]]//​ by //​[[CL:​Glossary:​import|importing]]//​ one of them into //package// and making it a shadowing symbol.
 +
 +====Examples====
 +<​blockquote>​
 +([[CL:​Functions:​export]] ([[CL:​Functions:​intern]] "​LAND-FILL"​ ([[CL:​Functions:​make-package]] '​trash)) '​trash) <​r>​[[CL:​Constant Variables:​T]] </r>
 +([[CL:​Functions:​find-symbol]] "​LAND-FILL"​ ([[CL:​Functions:​make-package]] '​temp)) <​r>​[[CL:​Constant Variables:​NIL]]
 +[[CL:​Constant Variables:​NIL]] </r>
 +([[CL:​Functions:​package-use-list]] 'temp) <​r>​(#<​PACKAGE "​TEMP">​) </r>
 +(use-package 'trash 'temp) <​r>​[[CL:​Constant Variables:​T]] </r>
 +([[CL:​Functions:​package-use-list]] 'temp) <​r>​(#<​PACKAGE "​TEMP">​ #<​PACKAGE "​TRASH">​) </r>
 +([[CL:​Functions:​find-symbol]] "​LAND-FILL"​ 'temp) <​r>​TRASH:​LAND-FILL
 +:INHERITED </r>
 +</​blockquote>​
 +
 +====Side Effects====
 +The //​[[CL:​Glossary:​use list]]// of //package// may be modified.
 +
 +====Affected By====
 +None.
 +
 +====Exceptional Situations====
 +None.
 +
 +====See Also====
 +  * **[[CL:​Functions:​unuse-package|Function UNUSE-PACKAGE]]**
 +  * **[[CL:​Functions:​package-use-list|Function PACKAGE-USE-LIST]]**
 +  * {\secref\PackageConcepts}
 +
 +====Notes====
 +It is permissible for a //​[[CL:​Glossary:​package]]//​ ''​P<​sub>​1</​sub>''​ to //​[[CL:​Glossary:​use]]//​ a //​[[CL:​Glossary:​package]]//​ ''​P<​sub>​2</​sub>''​ even if ''​P<​sub>​2</​sub>''​ already uses ''​P<​sub>​1</​sub>''​. The using of //​[[CL:​Glossary:​package|packages]]//​ is not transitive, so no problem results from the apparent circularity.
 +
 +\issue{PACKAGE-FUNCTION-CONSISTENCY:​MORE-PERMISSIVE}