dict-packages.tex 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562
  1. % -*- Mode: TeX -*-
  2. %-------------------- Package Type --------------------
  3. %% 2.8.0 1
  4. \begincom{package}\ftype{System Class}
  5. \label Class Precedence List::
  6. \typeref{package},
  7. \typeref{t}
  8. \label Description::
  9. A \term{package} is a \term{namespace} that maps \term{symbol} \term{names}
  10. to \term{symbols}; \seesection\PackageConcepts.
  11. \label See Also::
  12. {\secref\PackageConcepts},
  13. {\secref\PrintingOtherObjects},
  14. {\secref\SymbolTokens}
  15. \endcom%{package}\ftype{System Class}
  16. %%% ========== EXPORT
  17. \begincom{export}\ftype{Function}
  18. \label Syntax::
  19. \DefunWithValues export {symbols {\opt} package} {\t}
  20. \label Arguments and Values::
  21. \param{symbols}---a \term{designator} for a \term{list} of \term{symbols}.
  22. \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  23. \param{package}---a \term{package designator}.
  24. \endissue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  25. \Default{the \term{current package}}
  26. \label Description::
  27. %% 11.0.0 44
  28. %% 11.2.0 28
  29. \funref{export} makes one or more \param{symbols} that are \term{accessible}
  30. in \param{package} (whether directly or by inheritance) be \term{external symbols}
  31. of that \param{package}.
  32. If any of the \param{symbols} is already \term{accessible} as
  33. an \term{external symbol} of \param{package},
  34. \funref{export} has no effect on that \term{symbol}.
  35. If the \param{symbol} is
  36. %directly
  37. \term{present} in \param{package}
  38. as an internal symbol, it is simply changed to external status.
  39. If it is \term{accessible} as an \term{internal symbol} via \funref{use-package},
  40. %one of \param{symbols}
  41. it
  42. is first \term{imported} into \param{package},
  43. then \term{exported}.
  44. (The \param{symbol} is then \term{present} in the \param{package}
  45. whether or not \param{package} continues to use the \term{package} through
  46. which the \term{symbol} was originally inherited.)
  47. %% 11.0.0 50
  48. \funref{export} makes
  49. %one of \param{symbols} at a time
  50. each \param{symbol}
  51. \term{accessible} to all the \term{packages} that use \param{package}.
  52. All of these \term{packages} are checked for name conflicts:
  53. \f{(export \i{s} \i{p})} does
  54. \f{(find-symbol (symbol-name \i{s}) \i{q})} for each package \i{q}
  55. in \f{(package-used-by-list \i{p})}. Note that in the usual case of
  56. an \funref{export} during the initial definition of a \term{package},
  57. the
  58. result of \funref{package-used-by-list}
  59. is \nil\ and the name-conflict checking
  60. takes negligible time.
  61. When multiple changes are to be made,
  62. %however,
  63. for example when \funref{export}
  64. is given a \param{list} of \param{symbols}, it is
  65. permissible for the implementation to process each change separately,
  66. so that aborting from a name
  67. conflict caused by any but the first \param{symbol} in the
  68. \term{list} does not unexport the
  69. first \param{symbol} in the \param{list}.
  70. However, aborting from a name-conflict error
  71. caused by \funref{export}
  72. of one of \param{symbols} does not leave that \term{symbol}
  73. \term{accessible}
  74. to some \term{packages}
  75. and \term{inaccessible} to others; with respect to
  76. each of \param{symbols} processed, \funref{export}
  77. behaves as if it were as an atomic operation.
  78. %% 11.0.0 59
  79. A name conflict in \funref{export} between one of
  80. \param{symbols} being exported and a
  81. \term{symbol} already \term{present} in a \term{package}
  82. that would inherit the
  83. newly-exported \term{symbol}
  84. may be resolved in favor of the exported \term{symbol}
  85. by uninterning the other one, or in favor of the already-present
  86. \term{symbol} by making it a shadowing symbol.
  87. \label Examples::
  88. \code
  89. (make-package 'temp :use nil) \EV #<PACKAGE "TEMP">
  90. (use-package 'temp) \EV T
  91. (intern "TEMP-SYM" 'temp) \EV TEMP::TEMP-SYM, NIL
  92. (find-symbol "TEMP-SYM") \EV NIL, NIL
  93. (export (find-symbol "TEMP-SYM" 'temp) 'temp) \EV T
  94. (find-symbol "TEMP-SYM") \EV TEMP-SYM, :INHERITED
  95. \endcode
  96. \label Side Effects::
  97. The package system is modified.
  98. \label Affected By::
  99. \term{Accessible} \term{symbols}.
  100. \label Exceptional Situations::
  101. If any of the \param{symbols} is not \term{accessible} at all in \param{package},
  102. an error \oftype{package-error} is signaled that is \term{correctable}
  103. by permitting the \term{user}
  104. to interactively specify whether that \term{symbol} should be \term{imported}.
  105. %!!! Sandra: Something about name conflicts here?
  106. \label See Also::
  107. \funref{import},
  108. \funref{unexport},
  109. {\secref\PackageConcepts}
  110. \label Notes:\None.
  111. \endcom
  112. %%% ========== FIND-SYMBOL
  113. \begincom{find-symbol}\ftype{Function}
  114. \label Syntax::
  115. \DefunWithValues find-symbol {string {\opt} package} {symbol, status}
  116. \label Arguments and Values::
  117. \param{string}---a \term{string}.
  118. \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  119. \param{package}---a \term{package designator}.
  120. \endissue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  121. \Default{the \term{current package}}
  122. \param{symbol}---a \term{symbol} accessible in the \param{package},
  123. or \nil.
  124. \param{status}---one of \kwd{inherited}, \kwd{external}, \kwd{internal}, or \nil.
  125. \label Description::
  126. %% 11.2.0 24
  127. \funref{find-symbol} locates a \term{symbol} whose \term{name} is
  128. \param{string} in a \term{package}.
  129. If a \term{symbol} named \param{string} is found in \param{package},
  130. directly or by inheritance, the \term{symbol}
  131. found is returned as the first
  132. value; the second value is as follows:
  133. \beginlist
  134. \itemitem{\kwd{internal}}
  135. If the \term{symbol} is \term{present} in \param{package}
  136. as an \term{internal symbol}.
  137. \itemitem{\kwd{external}}
  138. If the \term{symbol} is \term{present} in \param{package}
  139. as an \term{external symbol}.
  140. \itemitem{\kwd{inherited}}
  141. If the \term{symbol} is inherited by \param{package}
  142. through \funref{use-package},
  143. % Added for Sandra:
  144. but is not \term{present} in \param{package}.
  145. \endlist
  146. If no such \term{symbol} is \term{accessible} in \param{package},
  147. both values are \nil.
  148. \label Examples::
  149. \code
  150. (find-symbol "NEVER-BEFORE-USED") \EV NIL, NIL
  151. (find-symbol "NEVER-BEFORE-USED") \EV NIL, NIL
  152. (intern "NEVER-BEFORE-USED") \EV NEVER-BEFORE-USED, NIL
  153. (intern "NEVER-BEFORE-USED") \EV NEVER-BEFORE-USED, :INTERNAL
  154. (find-symbol "NEVER-BEFORE-USED") \EV NEVER-BEFORE-USED, :INTERNAL
  155. (find-symbol "never-before-used") \EV NIL, NIL
  156. (find-symbol "CAR" 'common-lisp-user) \EV CAR, :INHERITED
  157. (find-symbol "CAR" 'common-lisp) \EV CAR, :EXTERNAL
  158. (find-symbol "NIL" 'common-lisp-user) \EV NIL, :INHERITED
  159. (find-symbol "NIL" 'common-lisp) \EV NIL, :EXTERNAL
  160. (find-symbol "NIL" (prog1 (make-package "JUST-TESTING" :use '())
  161. (intern "NIL" "JUST-TESTING")))
  162. \EV JUST-TESTING::NIL, :INTERNAL
  163. (export 'just-testing::nil 'just-testing)
  164. (find-symbol "NIL" 'just-testing) \EV JUST-TESTING:NIL, :EXTERNAL
  165. (find-symbol "NIL" "KEYWORD")
  166. \EV NIL, NIL
  167. \OV :NIL, :EXTERNAL
  168. (find-symbol (symbol-name :nil) "KEYWORD") \EV :NIL, :EXTERNAL
  169. \endcode
  170. \label Side Effects:\None.
  171. \label Affected By::
  172. \funref{intern},
  173. \funref{import},
  174. \funref{export},
  175. \funref{use-package},
  176. \funref{unintern},
  177. \funref{unexport},
  178. \funref{unuse-package}
  179. \label Exceptional Situations:\None.
  180. \label See Also::
  181. \funref{intern}, \funref{find-all-symbols}
  182. \label Notes::
  183. \funref{find-symbol} is operationally equivalent to \funref{intern},
  184. except that it never creates a new \term{symbol}.
  185. \endcom
  186. %%% ========== FIND-PACKAGE
  187. \begincom{find-package}\ftype{Function}
  188. \label Syntax::
  189. \DefunWithValues find-package {name} {package}
  190. \label Arguments and Values::
  191. %% Text of this dictionary entry slightly rearranged
  192. %% per Margolin #13 (first public review). -kmp 1-Jul-93
  193. \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  194. \param{name}---a \term{string designator} or a \term{package} \term{object}.
  195. \endissue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  196. \param{package}---a \term{package} \term{object} or \nil.
  197. \label Description::
  198. %% 11.2.0 12
  199. If \param{name} is a \term{string designator},
  200. \funref{find-package} locates and returns the
  201. \term{package} whose name or nickname is \param{name}.
  202. %% 11.0.0 21
  203. %The \funref{find-package}
  204. This
  205. search is case sensitive.
  206. If there is no such \term{package},
  207. \funref{find-package} returns \nil.
  208. \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  209. If \param{name} is a \term{package} \term{object},
  210. that \term{package} \term{object} is returned.
  211. \endissue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  212. \label Examples::
  213. \code
  214. (find-package 'common-lisp) \EV #<PACKAGE "COMMON-LISP">
  215. (find-package "COMMON-LISP-USER") \EV #<PACKAGE "COMMON-LISP-USER">
  216. (find-package 'not-there) \EV NIL
  217. \endcode
  218. \label Side Effects:\None.
  219. \label Affected By::
  220. The set of \term{packages} created by the \term{implementation}.
  221. \macref{defpackage},
  222. \funref{delete-package},
  223. \funref{make-package},
  224. \funref{rename-package}
  225. \label Exceptional Situations:\None.
  226. \label See Also::
  227. \funref{make-package}
  228. \label Notes:\None.
  229. \endcom
  230. %%% ========== FIND-ALL-SYMBOLS
  231. \begincom{find-all-symbols}\ftype{Function}
  232. \label Syntax::
  233. \DefunWithValues find-all-symbols {string} {symbols}
  234. \label Arguments and Values::
  235. \param{string}---a \term{\symbolnamedesignator}.
  236. \param{symbols}---a \term{list} of \term{symbols}.
  237. \label Description::
  238. %% 11.2.0 38
  239. \funref{find-all-symbols} searches
  240. \issue{PACKAGE-DELETION:NEW-FUNCTION} every \term{registered package}
  241. \endissue{PACKAGE-DELETION:NEW-FUNCTION} for \term{symbols} that have a
  242. \term{name} that is the \term{same} (under \funref{string=}) as
  243. \param{string}. A \term{list} of all such \term{symbols} is returned.
  244. Whether or how the \term{list} is ordered is
  245. \term{implementation-dependent}.
  246. \label Examples::
  247. \code
  248. (find-all-symbols 'car)
  249. \EV (CAR)
  250. \OV (CAR VEHICLES:CAR)
  251. \OV (VEHICLES:CAR CAR)
  252. (intern "CAR" (make-package 'temp :use nil)) \EV TEMP::CAR, NIL
  253. (find-all-symbols 'car)
  254. \EV (TEMP::CAR CAR)
  255. \OV (CAR TEMP::CAR)
  256. \OV (TEMP::CAR CAR VEHICLES:CAR)
  257. \OV (CAR TEMP::CAR VEHICLES:CAR)
  258. \endcode
  259. \label Side Effects:\None.
  260. \label Affected By:\None.
  261. \label Exceptional Situations:\None.
  262. \label See Also::
  263. \funref{find-symbol}
  264. \label Notes:\None.
  265. \endcom
  266. %%% ========== IMPORT
  267. \begincom{import}\ftype{Function}
  268. \label Syntax::
  269. \DefunWithValues import {symbols {\opt} package} {\t}
  270. \label Arguments and Values::
  271. \param{symbols}---a \term{designator} for a \term{list} of \term{symbols}.
  272. \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  273. \param{package}---a \term{package designator}.
  274. \endissue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  275. \Default{the \term{current package}}
  276. \label Description::
  277. %% 11.2.0 31
  278. %% 11.0.0 50
  279. \funref{import} adds \param{symbol} or
  280. \param{symbols} to the internals of \param{package}, checking for name
  281. conflicts with existing \term{symbols} either \term{present} in \param{package}
  282. or \term{accessible} to it. Once the \param{symbols} have been
  283. \term{imported}, they may be referenced in the \term{importing}
  284. \param{package} without the use of a \term{package prefix} when using the \term{Lisp reader}.
  285. %% 11.0.0 61
  286. A name conflict in \funref{import} between the
  287. \param{symbol} being imported and a symbol inherited from some other \term{package} can
  288. be resolved in favor of the
  289. \param{symbol} being \term{imported}
  290. by making it a shadowing symbol, or in favor
  291. of the \term{symbol} already \term{accessible} by
  292. not doing the \funref{import}. A
  293. name conflict in \funref{import} with a \term{symbol}
  294. already \term{present} in the
  295. \param{package}
  296. may be resolved by uninterning that \term{symbol}, or by not
  297. doing the \funref{import}.
  298. The imported \term{symbol} is
  299. not automatically exported from the \term{current package}, but if it is
  300. already \term{present} and external, then the fact that it
  301. is external is not changed.
  302. \issue{IMPORT-SETF-SYMBOL-PACKAGE}
  303. If any \term{symbol} to be \term{imported} has no home
  304. package (\ie {\tt (symbol-package \param{symbol}) \EV\ nil}),
  305. \funref{import} sets the \term{home package}
  306. of the \param{symbol} to \param{package}.
  307. \endissue{IMPORT-SETF-SYMBOL-PACKAGE}
  308. %% 11.0.0 37
  309. If the \param{symbol} is already \term{present} in the importing \param{package},
  310. \funref{import} has no effect.
  311. \label Examples::
  312. \code
  313. (import 'common-lisp::car (make-package 'temp :use nil)) \EV T
  314. (find-symbol "CAR" 'temp) \EV CAR, :INTERNAL
  315. (find-symbol "CDR" 'temp) \EV NIL, NIL
  316. \endcode
  317. The form \f{(import 'editor:buffer)} takes the external symbol named
  318. \f{buffer} in \thepackage{editor} (this symbol was located when the form
  319. was read by the \term{Lisp reader}) and adds it to the \term{current package}
  320. as an \term{internal symbol}. The symbol \f{buffer} is then \term{present} in
  321. the \term{current package}.
  322. \label Side Effects::
  323. The package system is modified.
  324. \label Affected By::
  325. Current state of the package system.
  326. \label Exceptional Situations::
  327. \funref{import} signals a \term{correctable} error \oftype{package-error}
  328. if any of the \param{symbols} to be \term{imported} has the \term{same} \term{name}
  329. (under \funref{string=}) as some distinct \term{symbol} (under \funref{eql})
  330. already \term{accessible} in the \param{package}, even if the conflict is
  331. with a \term{shadowing symbol} of the \param{package}.
  332. \label See Also::
  333. \funref{shadow}, \funref{export}
  334. \label Notes:\None.
  335. \endcom
  336. %%% ========== LIST-ALL-PACKAGES
  337. \begincom{list-all-packages}\ftype{Function}
  338. \label Syntax::
  339. \DefunWithValues list-all-packages {\noargs} {packages}
  340. \label Arguments and Values::
  341. \param{packages}---a \term{list} of \term{package} \term{objects}.
  342. \label Description::
  343. %% 11.2.0 19
  344. \funref{list-all-packages} returns a
  345. \issue{RESULT-LISTS-SHARED:SPECIFY}
  346. \term{fresh}
  347. \endissue{RESULT-LISTS-SHARED:SPECIFY}
  348. \term{list} of
  349. \issue{PACKAGE-DELETION:NEW-FUNCTION}
  350. all \term{registered packages}.
  351. \endissue{PACKAGE-DELETION:NEW-FUNCTION}
  352. \label Examples::
  353. \code
  354. (let ((before (list-all-packages)))
  355. (make-package 'temp)
  356. (set-difference (list-all-packages) before)) \EV (#<PACKAGE "TEMP">)
  357. \endcode
  358. \label Side Effects:\None.
  359. \label Affected By::
  360. \macref{defpackage},
  361. \funref{delete-package},
  362. \funref{make-package}
  363. \label Exceptional Situations:\None.
  364. %% Sandra thinks this is excessive.
  365. %Might signal \typeref{storage-condition}.
  366. \label See Also:\None.
  367. \label Notes:\None.
  368. \endcom
  369. %%% ========== RENAME-PACKAGE
  370. \begincom{rename-package}\ftype{Function}
  371. \label Syntax::
  372. \DefunWithValues rename-package {package new-name {\opt} new-nicknames} {package-object}
  373. \label Arguments and Values::
  374. \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  375. \param{package}---a \term{package designator}.
  376. \endissue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  377. \param{new-name}---a \term{package designator}.
  378. \param{new-nicknames}---a \term{list} of \term{\packagenamedesignators}.
  379. \Default{the \term{empty list}}
  380. \issue{RETURN-VALUES-UNSPECIFIED:SPECIFY}
  381. \param{package-object}---the renamed \param{package} \term{object}.
  382. \endissue{RETURN-VALUES-UNSPECIFIED:SPECIFY}
  383. \label Description::
  384. Replaces the name and nicknames of \param{package}.
  385. %% 11.2.0 15
  386. The old name and all of the old nicknames of \param{package} are eliminated
  387. and are replaced by \param{new-name} and \param{new-nicknames}.
  388. The consequences are undefined if \param{new-name} or any \param{new-nickname}
  389. conflicts with any existing package names.
  390. \label Examples::
  391. \code
  392. (make-package 'temporary :nicknames '("TEMP")) \EV #<PACKAGE "TEMPORARY">
  393. (rename-package 'temp 'ephemeral) \EV #<PACKAGE "EPHEMERAL">
  394. (package-nicknames (find-package 'ephemeral)) \EV ()
  395. (find-package 'temporary) \EV NIL
  396. (rename-package 'ephemeral 'temporary '(temp fleeting))
  397. \EV #<PACKAGE "TEMPORARY">
  398. (package-nicknames (find-package 'temp)) \EV ("TEMP" "FLEETING")
  399. \endcode
  400. \label Side Effects:\None.
  401. \label Affected By:\None.
  402. \label Exceptional Situations:\None.
  403. \label See Also::
  404. \funref{make-package}
  405. \label Notes:\None.
  406. \endcom
  407. %%% ========== SHADOW
  408. \begincom{shadow}\ftype{Function}
  409. \label Syntax::
  410. \DefunWithValues shadow {symbol-names {\opt} package} {\t}
  411. \label Arguments and Values::
  412. \issue{SHADOW-ALREADY-PRESENT:WORKS}
  413. \param{symbol-names}---a \term{designator} for
  414. a \term{list} of \term{\symbolnamedesignators}.
  415. \endissue{SHADOW-ALREADY-PRESENT:WORKS}
  416. \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  417. \param{package}---a \term{package designator}.
  418. \endissue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  419. \Default{the \term{current package}}
  420. \label Description::
  421. \funref{shadow} assures that \term{symbols} with names given
  422. by \param{symbol-names} are \term{present}
  423. %as \term{internal symbols} of
  424. in
  425. the \param{package}.
  426. %% 11.2.0 34
  427. Specifically, \param{package} is searched for \term{symbols}
  428. with the \term{names} supplied by \param{symbol-names}.
  429. \issue{SHADOW-ALREADY-PRESENT:WORKS}
  430. For each such \term{name}, if a corresponding \term{symbol}
  431. % oops! --sjl 7 Mar 92
  432. %is \term{present} in \param{package} (directly, not by inheritance),
  433. is not \term{present} in \param{package} (directly, not by inheritance),
  434. then a corresponding \term{symbol} is created with that \term{name},
  435. and inserted into \param{package} as an \term{internal symbol}.
  436. The corresponding \term{symbol}, whether pre-existing or newly created,
  437. is then added, if not already present, to the \term{shadowing symbols list}
  438. of \param{package}.
  439. \endissue{SHADOW-ALREADY-PRESENT:WORKS}
  440. \label Examples::
  441. \code
  442. (package-shadowing-symbols (make-package 'temp)) \EV NIL
  443. (find-symbol 'car 'temp) \EV CAR, :INHERITED
  444. (shadow 'car 'temp) \EV T
  445. (find-symbol 'car 'temp) \EV TEMP::CAR, :INTERNAL
  446. (package-shadowing-symbols 'temp) \EV (TEMP::CAR)
  447. \endcode
  448. %!!! What is this "should not error" biz, and what does USE-PACKAGE return...?
  449. \issue{SHADOW-ALREADY-PRESENT}
  450. \code
  451. (make-package 'test-1) \EV #<PACKAGE "TEST-1">
  452. (intern "TEST" (find-package 'test-1)) \EV TEST-1::TEST, NIL
  453. (shadow 'test-1::test (find-package 'test-1)) \EV T
  454. (shadow 'TEST (find-package 'test-1)) \EV T
  455. (assert (not (null (member 'test-1::test (package-shadowing-symbols
  456. (find-package 'test-1))))))
  457. (make-package 'test-2) \EV #<PACKAGE "TEST-2">
  458. (intern "TEST" (find-package 'test-2)) \EV TEST-2::TEST, NIL
  459. (export 'test-2::test (find-package 'test-2)) \EV T
  460. (use-package 'test-2 (find-package 'test-1)) ;should not error
  461. \endcode
  462. \endissue{SHADOW-ALREADY-PRESENT}
  463. \label Side Effects::
  464. %% 11.2.0 35
  465. \funref{shadow} changes the state of the package system in such a
  466. way that the package consistency rules do not hold across the change.
  467. \label Affected By::
  468. Current state of the package system.
  469. \label Exceptional Situations:\None.
  470. \label See Also::
  471. \funref{package-shadowing-symbols},
  472. %% ?? Ref ?? -kmp 22-Oct-91
  473. %``Character Reader'',
  474. {\secref\PackageConcepts}
  475. \label Notes::
  476. %% 11.0.0 52
  477. % \funref{shadow} does name-conflict checking to the extent that it
  478. % checks whether a distinct existing \term{symbol} with the same name
  479. % as one of \param{symbol-names} is \term{accessible} and, if so, whether
  480. % it is directly \term{present} in \param{package} or inherited. In the
  481. % latter case, a new \term{symbol} is created to shadow it.
  482. If a \term{symbol} with a name in \param{symbol-names} already exists
  483. in \param{package}, but by inheritance, the inherited symbol becomes
  484. \term{shadowed}\meaning{3} by a newly created \term{internal symbol}.
  485. \endcom
  486. %%% ========== SHADOWING-IMPORT
  487. \begincom{shadowing-import}\ftype{Function}
  488. \label Syntax::
  489. \DefunWithValues shadowing-import {symbols {\opt} package} {\t}
  490. \label Arguments and Values::
  491. \param{symbols}---a \term{designator} for a \term{list} of \term{symbols}.
  492. \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  493. \param{package} ---a \term{package designator}.
  494. \endissue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  495. \Default{the \term{current package}}
  496. \label Description::
  497. %% 11.2.0 32
  498. \funref{shadowing-import} is like \funref{import},
  499. but it does not signal an error even if the importation of a \term{symbol}
  500. would shadow some \term{symbol} already \term{accessible} in \param{package}.
  501. %% 11.0.0 38
  502. \funref{shadowing-import} inserts each of \param{symbols}
  503. into \param{package} as an internal symbol, regardless
  504. of whether another \term{symbol} of the same name is shadowed by this
  505. action.
  506. If a different \term{symbol} of the same name is already \term{present}
  507. in \param{package},
  508. that \term{symbol} is first \term{uninterned} from \param{package}.
  509. The new \term{symbol} is added to \param{package}'s shadowing-symbols list.
  510. %% 11.0.0 52
  511. \funref{shadowing-import} does name-conflict
  512. checking to the extent that it checks whether a distinct existing
  513. \term{symbol} with the same name is \term{accessible}; if so, it is shadowed by
  514. the new \term{symbol}, which implies that it must be uninterned
  515. if it was
  516. %directly
  517. \term{present} in \param{package}.
  518. \label Examples::
  519. \code
  520. (in-package "COMMON-LISP-USER") \EV #<PACKAGE "COMMON-LISP-USER">
  521. (setq sym (intern "CONFLICT")) \EV CONFLICT
  522. (intern "CONFLICT" (make-package 'temp)) \EV TEMP::CONFLICT, NIL
  523. (package-shadowing-symbols 'temp) \EV NIL
  524. (shadowing-import sym 'temp) \EV T
  525. (package-shadowing-symbols 'temp) \EV (CONFLICT)
  526. \endcode
  527. \label Side Effects::
  528. %% 11.2.0 33
  529. \funref{shadowing-import}
  530. changes the state of the package system in such a way that
  531. the consistency rules do not hold across the change.
  532. \param{package}'s shadowing-symbols list is modified.
  533. \label Affected By::
  534. Current state of the package system.
  535. \label Exceptional Situations:\None.
  536. \label See Also::
  537. \funref{import}, \funref{unintern}, \funref{package-shadowing-symbols}
  538. \label Notes:\None.
  539. \endcom
  540. %%% ========== DELETE-PACKAGE
  541. \begincom{delete-package}\ftype{Function}
  542. \issue{PACKAGE-DELETION:NEW-FUNCTION}
  543. \label Syntax::
  544. \DefunWithValues delete-package {package} {generalized-boolean}
  545. \label Arguments and Values::
  546. \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  547. \param{package}---a \term{package designator}.
  548. \endissue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  549. \param{generalized-boolean}---a \term{generalized boolean}.
  550. \label Description::
  551. \funref{delete-package} deletes \param{package} from all package system
  552. data structures.
  553. %% KC addition
  554. If the operation is successful, \funref{delete-package} returns
  555. true, otherwise \nil.
  556. %% end KC addition
  557. The effect of \funref{delete-package} is that the name and nicknames
  558. of \param{package} cease to be recognized package names.
  559. The package \term{object} is still a \term{package}
  560. (\ie \funref{packagep} is \term{true} of it)
  561. but \funref{package-name} returns \nil.
  562. %% KC addition
  563. The consequences of deleting \thepackage{common-lisp} or \thepackage{keyword} are undefined.
  564. %% end KC addition
  565. The consequences of invoking any other package operation on \param{package}
  566. once it has been deleted are unspecified.
  567. In particular, the consequences of invoking \funref{find-symbol},
  568. \funref{intern} and other functions that look for a symbol name in
  569. a \term{package} are unspecified if they are called with \varref{*package*}
  570. bound to the deleted \param{package} or with the deleted \param{package}
  571. as an argument.
  572. If \param{package} is a \term{package} \term{object} that has already
  573. been deleted, \funref{delete-package} immediately returns \nil.
  574. After this operation completes, the
  575. %contents of the \funref{symbol-package} slot
  576. \term{home package}
  577. of any \term{symbol} whose \term{home package}
  578. %is
  579. had previously been
  580. \param{package}
  581. %are
  582. is
  583. %unspecified
  584. \term{implementation-dependent}.
  585. Except for this, \term{symbols} \term{accessible}
  586. in \param{package} are not modified in any other way;
  587. \term{symbols} whose \term{home package} is not \param{package} remain unchanged.
  588. \label Examples::
  589. \code
  590. (setq *foo-package* (make-package "FOO" :use nil))
  591. (setq *foo-symbol* (intern "FOO" *foo-package*))
  592. (export *foo-symbol* *foo-package*)
  593. (setq *bar-package* (make-package "BAR" :use '("FOO")))
  594. (setq *bar-symbol* (intern "BAR" *bar-package*))
  595. (export *foo-symbol* *bar-package*)
  596. (export *bar-symbol* *bar-package*)
  597. (setq *baz-package* (make-package "BAZ" :use '("BAR")))
  598. (symbol-package *foo-symbol*) \EV #<PACKAGE "FOO">
  599. (symbol-package *bar-symbol*) \EV #<PACKAGE "BAR">
  600. (prin1-to-string *foo-symbol*) \EV "FOO:FOO"
  601. (prin1-to-string *bar-symbol*) \EV "BAR:BAR"
  602. (find-symbol "FOO" *bar-package*) \EV FOO:FOO, :EXTERNAL
  603. (find-symbol "FOO" *baz-package*) \EV FOO:FOO, :INHERITED
  604. (find-symbol "BAR" *baz-package*) \EV BAR:BAR, :INHERITED
  605. (packagep *foo-package*) \EV \term{true}
  606. (packagep *bar-package*) \EV \term{true}
  607. (packagep *baz-package*) \EV \term{true}
  608. (package-name *foo-package*) \EV "FOO"
  609. (package-name *bar-package*) \EV "BAR"
  610. (package-name *baz-package*) \EV "BAZ"
  611. (package-use-list *foo-package*) \EV ()
  612. (package-use-list *bar-package*) \EV (#<PACKAGE "FOO">)
  613. (package-use-list *baz-package*) \EV (#<PACKAGE "BAR">)
  614. (package-used-by-list *foo-package*) \EV (#<PACKAGE "BAR">)
  615. (package-used-by-list *bar-package*) \EV (#<PACKAGE "BAZ">)
  616. (package-used-by-list *baz-package*) \EV ()
  617. (delete-package *bar-package*)
  618. \OUT Error: Package BAZ uses package BAR.
  619. \OUT If continued, BAZ will be made to unuse-package BAR,
  620. \OUT and then BAR will be deleted.
  621. \OUT Type :CONTINUE to continue.
  622. \OUT Debug> \IN{:CONTINUE}
  623. \EV T
  624. (symbol-package *foo-symbol*) \EV #<PACKAGE "FOO">
  625. (symbol-package *bar-symbol*) is unspecified
  626. (prin1-to-string *foo-symbol*) \EV "FOO:FOO"
  627. (prin1-to-string *bar-symbol*) is unspecified
  628. (find-symbol "FOO" *bar-package*) is unspecified
  629. (find-symbol "FOO" *baz-package*) \EV NIL, NIL
  630. (find-symbol "BAR" *baz-package*) \EV NIL, NIL
  631. (packagep *foo-package*) \EV T
  632. (packagep *bar-package*) \EV T
  633. (packagep *baz-package*) \EV T
  634. (package-name *foo-package*) \EV "FOO"
  635. (package-name *bar-package*) \EV NIL
  636. (package-name *baz-package*) \EV "BAZ"
  637. (package-use-list *foo-package*) \EV ()
  638. (package-use-list *bar-package*) is unspecified
  639. (package-use-list *baz-package*) \EV ()
  640. (package-used-by-list *foo-package*) \EV ()
  641. (package-used-by-list *bar-package*) is unspecified
  642. (package-used-by-list *baz-package*) \EV ()
  643. \endcode
  644. \label Affected By:\None.
  645. \label Exceptional Situations::
  646. If the \param{package} \term{designator} is a \term{name} that does not
  647. currently name a \term{package},
  648. a \term{correctable} error \oftype{package-error} is signaled.
  649. If correction is attempted, no deletion action is attempted;
  650. instead, \funref{delete-package} immediately returns \nil.
  651. If \param{package} is used by other \term{packages},
  652. a \term{correctable} error \oftype{package-error} is signaled.
  653. If correction is attempted,
  654. \funref{unuse-package} is effectively called to remove any dependencies,
  655. causing \param{package}'s \term{external symbols} to cease being \term{accessible} to those
  656. \term{packages} that use \param{package}.
  657. \funref{delete-package} then deletes \param{package} just as it would have had
  658. there been no \term{packages} that used it.
  659. \label See Also::
  660. \funref{unuse-package}
  661. %% Per X3J13. -kmp 05-Oct-93
  662. \label Notes:\None.
  663. \endissue{PACKAGE-DELETION:NEW-FUNCTION}
  664. \endcom
  665. %%% ========== MAKE-PACKAGE
  666. \begincom{make-package}\ftype{Function}
  667. \label Syntax::
  668. \DefunWithValues make-package {package-name {\key} nicknames use} {package}
  669. \label Arguments and Values::
  670. \param{package-name}---a \term{\packagenamedesignator}.
  671. \param{nicknames}---a \term{list} of \term{\packagenamedesignators}.
  672. \Default{the \term{empty list}}
  673. \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  674. %% 11.2.0 9
  675. \param{use}---%
  676. %a \term{designator} for
  677. a \term{list} of \term{package designators}.
  678. \issue{MAKE-PACKAGE-USE-DEFAULT:IMPLEMENTATION-DEPENDENT}
  679. \Default{\term{implementation-defined}}
  680. \endissue{MAKE-PACKAGE-USE-DEFAULT:IMPLEMENTATION-DEPENDENT}
  681. \endissue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  682. \param{package}---a \term{package}.
  683. \label Description::
  684. %% 11.2.0 8
  685. Creates a new \term{package} with the name \param{package-name}.
  686. \param{Nicknames} are additional \term{names} which may be used
  687. to refer to the new \term{package}.
  688. \param{use} specifies zero or more \term{packages}
  689. the \term{external symbols} of which are to be inherited by
  690. the new \term{package}. \Seefun{use-package}.
  691. \label Examples::
  692. \code
  693. (make-package 'temporary :nicknames '("TEMP" "temp")) \EV #<PACKAGE "TEMPORARY">
  694. (make-package "OWNER" :use '("temp")) \EV #<PACKAGE "OWNER">
  695. (package-used-by-list 'temp) \EV (#<PACKAGE "OWNER">)
  696. (package-use-list 'owner) \EV (#<PACKAGE "TEMPORARY">)
  697. \endcode
  698. \label Side Effects:\None.
  699. \label Affected By::
  700. The existence of other \term{packages} in the system.
  701. \label Exceptional Situations::
  702. The consequences are unspecified if \term{packages} denoted by \param{use}
  703. do not exist.
  704. A \term{correctable} error is signaled if the \param{package-name}
  705. or any of the \param{nicknames} is already
  706. the \term{name} or \term{nickname} of an existing \term{package}.
  707. \label See Also::
  708. \macref{defpackage},
  709. \funref{use-package}
  710. \label Notes::
  711. In situations where the \term{packages} to be used contain symbols which would conflict,
  712. it is necessary to first create the package with \f{:use '()},
  713. then to use \funref{shadow} or \funref{shadowing-import} to address the conflicts,
  714. and then after that to use \funref{use-package} once the conflicts have been addressed.
  715. When packages are being created as part of the static definition of a program
  716. rather than dynamically by the program, it is generally considered more stylistically
  717. appropriate to use \macref{defpackage} rather than \funref{make-package}.
  718. \endcom
  719. %%% ========== WITH-PACKAGE-ITERATOR
  720. \begincom{with-package-iterator}\ftype{Macro}
  721. \issue{DECLS-AND-DOC}
  722. \issue{HASH-TABLE-PACKAGE-GENERATORS:ADD-WITH-WRAPPER}
  723. \label Syntax::
  724. \DefmacWithValuesNewline with-package-iterator
  725. {\paren{name package-list-form {\rest} {symbol-types}}
  726. \starparam{declaration} \starparam{form}}
  727. {\starparam{result}}
  728. \label Arguments and Values::
  729. % ughh. -sjl 7 Mar 92
  730. %\param{name}---a name suitable for the first argument to \specref{macrolet}.
  731. \param{name}---a \term{symbol}.
  732. \param{package-list-form}---a \term{form}; evaluated once to produce a \param{package-list}.
  733. \param{package-list}---a \term{designator} for a list of \term{package designators}.
  734. \param{symbol-type}---one of the \term{symbols}
  735. \kwd{internal}, \kwd{external}, or \kwd{inherited}.
  736. \param{declaration}---a \misc{declare} \term{expression}; \noeval.
  737. \param{forms}---an \term{implicit progn}.
  738. \param{results}---the \term{values} of the \param{forms}.
  739. \label Description::
  740. Within the lexical scope of the body \param{forms},
  741. the \param{name} is defined via \specref{macrolet}
  742. such that successive invocations of {\tt (\param{name})}
  743. will return the \term{symbols}, one by one,
  744. from the \term{packages} in \param{package-list}.
  745. It is unspecified whether \term{symbols} inherited from
  746. multiple \term{packages} are returned more than once.
  747. The order of \term{symbols} returned does not necessarily reflect the order
  748. of \term{packages} in \param{package-list}. When \param{package-list} has
  749. more than one element, it is unspecified whether duplicate \term{symbols} are
  750. returned once or more than once.
  751. \param{Symbol-types} controls which \term{symbols} that are \term{accessible}
  752. in a \term{package} are returned as follows:
  753. \beginlist
  754. \itemitem{\kwd{internal}}
  755. The \term{symbols} that are \term{present} in the \term{package},
  756. but that are not \term{exported}.
  757. \itemitem{\kwd{external}}
  758. The \term{symbols} that are \term{present} in the \term{package}
  759. and are \term{exported}.
  760. \itemitem{\kwd{inherited}}
  761. The \term{symbols} that are \term{exported} by used \term{packages}
  762. and that are not \term{shadowed}.
  763. \endlist
  764. When more than one argument is supplied for \param{symbol-types},
  765. a \term{symbol} is returned if its \term{accessibility} matches
  766. any one of the \param{symbol-types} supplied.
  767. Implementations may extend this syntax by recognizing additional
  768. symbol accessibility types.
  769. An invocation of {\tt (\param{name})} returns four values as follows:
  770. \beginlist
  771. \itemitem{1.} A flag that indicates whether a \term{symbol} is returned
  772. (true means that a \term{symbol} is returned).
  773. \itemitem{2.} A \term{symbol} that is \term{accessible} in one the
  774. indicated \term{packages}.
  775. \itemitem{3.} The accessibility type for that \term{symbol};
  776. \ie one of the symbols \kwd{internal}, \kwd{external}, or \kwd{inherited}.
  777. \itemitem{4.} The \term{package} from which the \term{symbol} was obtained.
  778. The \term{package} is one of the \term{packages} present
  779. or named in \param{package-list}.
  780. \endlist
  781. After all \term{symbols} have been returned by successive invocations of
  782. {\tt (\param{name})}, then only one value is returned, namely \nil.
  783. The meaning of the second, third, and fourth \term{values} is that the returned
  784. \term{symbol} is \term{accessible} in the returned \term{package}
  785. in the way indicated by the second return value as follows:
  786. \beginlist
  787. \itemitem{\kwd{internal}}
  788. Means \term{present} and not \term{exported}.
  789. \itemitem{\kwd{external}}
  790. Means \term{present} and \term{exported}.
  791. \itemitem{\kwd{inherited}}
  792. Means not \term{present} (thus not \term{shadowed}) but inherited
  793. from some used \term{package}.
  794. \endlist
  795. It is unspecified what happens if any of the implicit interior state
  796. of an iteration is returned outside the dynamic extent of the
  797. \macref{with-package-iterator}
  798. form such as by returning some \term{closure} over the invocation \term{form}.
  799. Any number of invocations of \macref{with-package-iterator}
  800. can be nested, and the body of the innermost one can invoke all of the
  801. locally \term{established} \term{macros}, provided all those \term{macros}
  802. have distinct names.
  803. \label Examples::
  804. The following function should return \t\ on any \term{package}, and signal
  805. an error if the usage of \macref{with-package-iterator} does not agree
  806. with the corresponding usage of \macref{do-symbols}.
  807. \code
  808. (defun test-package-iterator (package)
  809. (unless (packagep package)
  810. (setq package (find-package package)))
  811. (let ((all-entries '())
  812. (generated-entries '()))
  813. (do-symbols (x package)
  814. (multiple-value-bind (symbol accessibility)
  815. (find-symbol (symbol-name x) package)
  816. (push (list symbol accessibility) all-entries)))
  817. (with-package-iterator (generator-fn package
  818. :internal :external :inherited)
  819. (loop
  820. (multiple-value-bind (more? symbol accessibility pkg)
  821. (generator-fn)
  822. (unless more? (return))
  823. (let ((l (multiple-value-list (find-symbol (symbol-name symbol)
  824. package))))
  825. (unless (equal l (list symbol accessibility))
  826. (error "Symbol ~S not found as ~S in package ~A [~S]"
  827. symbol accessibility (package-name package) l))
  828. (push l generated-entries)))))
  829. (unless (and (subsetp all-entries generated-entries :test #'equal)
  830. (subsetp generated-entries all-entries :test #'equal))
  831. (error "Generated entries and Do-Symbols entries don't correspond"))
  832. t))
  833. \endcode
  834. The following function prints out every \term{present} \term{symbol}
  835. (possibly more than once):
  836. \code
  837. (defun print-all-symbols ()
  838. (with-package-iterator (next-symbol (list-all-packages)
  839. :internal :external)
  840. (loop
  841. (multiple-value-bind (more? symbol) (next-symbol)
  842. (if more?
  843. (print symbol)
  844. (return))))))
  845. \endcode
  846. \label Side Effects:\None.
  847. \label Affected By:\None.
  848. \label Exceptional Situations::
  849. \macref{with-package-iterator} signals an error \oftype{program-error} if
  850. no \param{symbol-types} are supplied or if a \param{symbol-type} is not
  851. recognized by the implementation is supplied.
  852. The consequences are undefined if the local function named \param{name}
  853. \term{established} by \macref{with-package-iterator} is called after it
  854. has returned \term{false} as its \term{primary value}.
  855. \label See Also::
  856. \issue{MAPPING-DESTRUCTIVE-INTERACTION:EXPLICITLY-VAGUE}
  857. {\secref\TraversalRules}
  858. \endissue{MAPPING-DESTRUCTIVE-INTERACTION:EXPLICITLY-VAGUE}
  859. \label Notes:\None.
  860. \endissue{HASH-TABLE-PACKAGE-GENERATORS:ADD-WITH-WRAPPER}
  861. \endissue{DECLS-AND-DOC}
  862. \endcom
  863. %%% ========== UNEXPORT
  864. \begincom{unexport}\ftype{Function}
  865. \label Syntax::
  866. \DefunWithValues unexport {symbols {\opt} package} {\t}
  867. \label Arguments and Values::
  868. \param{symbols}---a \term{designator} for a \term{list} of \term{symbols}.
  869. \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  870. \param{package}---a \term{package designator}.
  871. \endissue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  872. \Default{the \term{current package}}
  873. \label Description::
  874. %% 11.2.0 30
  875. \funref{unexport} reverts external \param{symbols} in \param{package} to
  876. internal status; it undoes the effect of \funref{export}.
  877. %% 11.0.0 45
  878. %!!! Can this really be true? -kmp 25-Apr-91
  879. \funref{unexport} works only on \term{symbols}
  880. %directly
  881. \term{present}
  882. in \param{package}, switching them back to internal status.
  883. If \funref{unexport} is given a \term{symbol} that is
  884. already \term{accessible} as an \term{internal symbol} in \param{package},
  885. it does nothing.
  886. \label Examples::
  887. \code
  888. (in-package "COMMON-LISP-USER") \EV #<PACKAGE "COMMON-LISP-USER">
  889. (export (intern "CONTRABAND" (make-package 'temp)) 'temp) \EV T
  890. (find-symbol "CONTRABAND") \EV NIL, NIL
  891. (use-package 'temp) \EV T
  892. (find-symbol "CONTRABAND") \EV CONTRABAND, :INHERITED
  893. (unexport 'contraband 'temp) \EV T
  894. (find-symbol "CONTRABAND") \EV NIL, NIL
  895. \endcode
  896. \label Side Effects::
  897. Package system is modified.
  898. \label Affected By::
  899. Current state of the package system.
  900. \label Exceptional Situations::
  901. If \funref{unexport} is given a \term{symbol}
  902. not \term{accessible} in \param{package} at all,
  903. an error \oftype{package-error} is signaled.
  904. The consequences are undefined if \param{package} is \thepackage{keyword}
  905. %added for Sandra:
  906. or \thepackage{common-lisp}.
  907. \label See Also::
  908. \funref{export}, {\secref\PackageConcepts}
  909. \label Notes:\None.
  910. \endcom
  911. %%% ========== UNINTERN
  912. \begincom{unintern}\ftype{Function}
  913. \label Syntax::
  914. \DefunWithValues unintern {symbol {\opt} package} {generalized-boolean}
  915. \label Arguments and Values::
  916. \param{symbol}---a \term{symbol}.
  917. \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  918. \param{package}---a \term{package designator}.
  919. \endissue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  920. \Default{the \term{current package}}
  921. \param{generalized-boolean}---a \term{generalized boolean}.
  922. \label Description::
  923. \funref{unintern} removes \param{symbol} from \param{package}.
  924. %% 11.2.0 25
  925. If \param{symbol} is \term{present} in \param{package}, it is
  926. removed from \param{package} and also from \param{package}'s
  927. \term{shadowing symbols list} if it is present there. If \param{package} is the
  928. \term{home package} for \param{symbol}, \param{symbol} is made to have no
  929. \term{home package}.
  930. \param{Symbol} may continue to be \term{accessible}
  931. in \param{package} by inheritance.
  932. Use of \funref{unintern} can result in a \term{symbol}
  933. that has no
  934. recorded \term{home package},
  935. but that in fact is \term{accessible} in some \term{package}.
  936. \clisp\ does not check for this pathological case,
  937. and such \term{symbols}
  938. are always printed preceded by \f{\#:}.
  939. \funref{unintern} returns \term{true} if it removes \param{symbol}, and \nil\ otherwise.
  940. \label Examples::
  941. \code
  942. (in-package "COMMON-LISP-USER") \EV #<PACKAGE "COMMON-LISP-USER">
  943. (setq temps-unpack (intern "UNPACK" (make-package 'temp))) \EV TEMP::UNPACK
  944. (unintern temps-unpack 'temp) \EV T
  945. (find-symbol "UNPACK" 'temp) \EV NIL, NIL
  946. temps-unpack \EV #:UNPACK
  947. \endcode
  948. \label Side Effects::
  949. %% 11.2.0 26
  950. \funref{unintern} changes the state of the
  951. package system in such a way that the consistency rules do not hold
  952. across the change.
  953. \label Affected By::
  954. Current state of the package system.
  955. \label Exceptional Situations::
  956. %% 11.0.0 54
  957. Giving a shadowing symbol to \funref{unintern}
  958. can uncover a name conflict that had
  959. previously been resolved by the shadowing. If package A uses packages
  960. B and C, A contains a shadowing symbol \f{x}, and B and C each contain external
  961. symbols named \f{x}, then removing the shadowing symbol \f{x}
  962. from A will reveal a name
  963. conflict between \f{b:x} and \f{c:x} if those two \term{symbols} are distinct.
  964. In this case \funref{unintern} will signal an error.
  965. %!!! Barmar: Of type??
  966. \label See Also::
  967. {\secref\PackageConcepts}
  968. \label Notes:\None.
  969. \endcom
  970. %%% ========== IN-PACKAGE
  971. \begincom{in-package}\ftype{Macro}
  972. \issue{IN-PACKAGE-FUNCTIONALITY:MAR89-X3J13}
  973. \label Syntax::
  974. \DefmacWithValues in-package {name} {package}
  975. \label Arguments and Values::
  976. \param{name}---a \term{\packagenamedesignator}; \noeval.
  977. \param{package}---the \term{package} named by \param{name}.
  978. \label Description::
  979. %%% 11.2.0 10
  980. %%% 11.2.0 11
  981. %%% Issue MAKE-PACKAGE-USE-DEFAULT IN-PACKAGE-FUNCTIONALITY:MAR89-X3J13.
  982. Causes the the \term{package} named by \param{name}
  983. to become the \term{current package}---that is, \thevalueof{*package*}.
  984. If no such \term{package} already exists, an error \oftype{package-error} is signaled.
  985. Everything \macref{in-package} does is also performed at compile time
  986. if the call appears as a \term{top level form}.
  987. \label Examples:\None.
  988. %Old examples removed as irrelevant.
  989. %Need to come up with something new. -kmp 25-Apr-91
  990. \label Side Effects::
  991. \Thevariable{*package*} is assigned.
  992. If the \macref{in-package} \term{form} is a \term{top level form},
  993. this assignment also occurs at compile time.
  994. \label Affected By:\None.
  995. \label Exceptional Situations::
  996. An error \oftype{package-error} is signaled if the specified \term{package} does not exist.
  997. \label See Also::
  998. \varref{*package*}
  999. %% Per X3J13. -kmp 05-Oct-93
  1000. \label Notes:\None.
  1001. \endissue{IN-PACKAGE-FUNCTIONALITY:MAR89-X3J13}
  1002. \endcom
  1003. %%% ========== UNUSE-PACKAGE
  1004. \begincom{unuse-package}\ftype{Function}
  1005. \label Syntax::
  1006. \DefunWithValues unuse-package {packages-to-unuse {\opt} package} {\t}
  1007. \label Arguments and Values::
  1008. \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  1009. \param{packages-to-unuse}---a \term{designator} for
  1010. a \term{list} of \term{package designators}.
  1011. \endissue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  1012. % Issue PACKAGE-FUNCTION-CONSISTENCY is silent on whether a "package designator"
  1013. % is really the right thing here, but KAB, Sandra, and KMP agree that this is what
  1014. % was probably intended.
  1015. \param{package}---a \term{package designator}.
  1016. \Default{the \term{current package}}
  1017. \label Description::
  1018. %% 11.2.0 37
  1019. \funref{unuse-package} causes \param{package} to cease inheriting
  1020. all the \term{external symbols} of
  1021. \param{packages-to-unuse}; \funref{unuse-package} undoes
  1022. the effects of \funref{use-package}. The
  1023. \param{packages-to-unuse}
  1024. are removed from the \term{use list} of \param{package}.
  1025. %% Sandra: Redundant.
  1026. % The \term{external symbols} of the \param{packages-to-unuse} are no longer inherited.
  1027. % However,
  1028. Any \term{symbols} that have been
  1029. \term{imported} into \param{package} continue to be \term{present} in \param{package}.
  1030. \label Examples::
  1031. \code
  1032. (in-package "COMMON-LISP-USER") \EV #<PACKAGE "COMMON-LISP-USER">
  1033. (export (intern "SHOES" (make-package 'temp)) 'temp) \EV T
  1034. (find-symbol "SHOES") \EV NIL, NIL
  1035. (use-package 'temp) \EV T
  1036. (find-symbol "SHOES") \EV SHOES, :INHERITED
  1037. (find (find-package 'temp) (package-use-list 'common-lisp-user)) \EV #<PACKAGE "TEMP">
  1038. (unuse-package 'temp) \EV T
  1039. (find-symbol "SHOES") \EV NIL, NIL
  1040. \endcode
  1041. \label Side Effects::
  1042. The \term{use list} of \param{package} is modified.
  1043. \label Affected By::
  1044. Current state of the package system.
  1045. \label Exceptional Situations:\None.
  1046. \label See Also::
  1047. \funref{use-package}, \funref{package-use-list}
  1048. \label Notes:\None.
  1049. \endcom
  1050. %%% ========== USE-PACKAGE
  1051. \begincom{use-package}\ftype{Function}
  1052. \label Syntax::
  1053. \DefunWithValues use-package {packages-to-use {\opt} package} {\t}
  1054. \label Arguments and Values::
  1055. %% 11.0.0 27
  1056. \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  1057. \param{packages-to-use}---a \term{designator} for
  1058. a \term{list} of \term{package designators}.
  1059. \Thepackage{keyword} may not be supplied.
  1060. % Issue PACKAGE-FUNCTION-CONSISTENCY is silent on whether a "package designator"
  1061. % is really the right thing here, but KAB, Sandra, and KMP agree that this is what
  1062. % was probably intended.
  1063. \param{package}---a \term{package designator}.
  1064. \Default{the \term{current package}}
  1065. %% Next sentence reworded and moved per Boyer/Kaufmann/Moore #12
  1066. %% (by X3J13 vote at May 4-5, 1994 meeting)
  1067. %% -kmp 9-May-94
  1068. % \Thepackage{keyword} cannot be supplied.
  1069. The \param{package} cannot be \thepackage{keyword}.
  1070. \endissue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  1071. \label Description::
  1072. \funref{use-package} causes \param{package} to inherit all the
  1073. \term{external symbols} of \param{packages-to-use}.
  1074. The inherited \term{symbols} become \term{accessible} as
  1075. \term{internal symbols} of \param{package}.
  1076. %% 11.2.0 36
  1077. \param{Packages-to-use} are added to the \term{use list} of \param{package}
  1078. if they are not there already. All \term{external symbols} in
  1079. \param{packages-to-use} become \term{accessible} in \param{package}
  1080. as \term{internal symbols}.
  1081. %% 11.0.0 50
  1082. %% Sandra thinks this follows form what it is to be accessible as internal symbols.
  1083. % The new \term{symbols} can be referred to without a \term{package prefix}
  1084. % while \param{package} is current, but they are not passed along to any
  1085. % other \term{package} that uses \param{package}.
  1086. \funref{use-package} does not cause any new \term{symbols} to be \term{present}
  1087. in \param{package} but only makes them \term{accessible} by inheritance.
  1088. %% 11.0.0 39
  1089. \funref{use-package} checks for
  1090. name conflicts between the newly imported symbols and those already
  1091. \term{accessible} in \param{package}.
  1092. %% 11.0.0 58
  1093. A name conflict in \funref{use-package}
  1094. between two external symbols inherited
  1095. by \param{package} from \param{packages-to-use} may be resolved in favor of
  1096. either \term{symbol}
  1097. by \term{importing} one of them into \param{package} and making it a
  1098. shadowing symbol.
  1099. \label Examples::
  1100. \code
  1101. (export (intern "LAND-FILL" (make-package 'trash)) 'trash) \EV T
  1102. (find-symbol "LAND-FILL" (make-package 'temp)) \EV NIL, NIL
  1103. (package-use-list 'temp) \EV (#<PACKAGE "TEMP">)
  1104. (use-package 'trash 'temp) \EV T
  1105. (package-use-list 'temp) \EV (#<PACKAGE "TEMP"> #<PACKAGE "TRASH">)
  1106. (find-symbol "LAND-FILL" 'temp) \EV TRASH:LAND-FILL, :INHERITED
  1107. \endcode
  1108. \label Side Effects::
  1109. The \term{use list} of \param{package} may be modified.
  1110. \label Affected By:\None.
  1111. \label Exceptional Situations:\None.%!!! Barmar: What about name conflicts?
  1112. \label See Also::
  1113. \funref{unuse-package},
  1114. \funref{package-use-list},
  1115. {\secref\PackageConcepts}
  1116. \label Notes::
  1117. It is permissible for a \term{package} $P\sub 1$
  1118. to \term{use} a \term{package} $P\sub 2$
  1119. even if $P\sub 2$ already uses $P\sub 1$.
  1120. The using of \term{packages} is not transitive,
  1121. so no problem results from the apparent circularity.
  1122. \endcom
  1123. %%% ========== DEFPACKAGE
  1124. \begincom{defpackage}\ftype{Macro}
  1125. \issue{DEFPACKAGE:ADDITION}
  1126. %!!! Interchange param names "defined-package-name" and "package-name" here.
  1127. \label Syntax::
  1128. \DefmacWithValues defpackage
  1129. {defined-package-name \interleave{\down{option}}}
  1130. {package}
  1131. \issue{DOCUMENTATION-FUNCTION-BUGS:FIX}
  1132. % All options except :size can appear more than once.
  1133. \auxbnf{option}{\starparen{\kwd{nicknames} \starparam{nickname}} | \CR
  1134. \paren{\kwd{documentation} \i{string}} | \CR
  1135. \starparen{\kwd{use} \starparam{package-name}} | \CR
  1136. \starparen{\kwd{shadow} \stardown{symbol-name}} | \CR
  1137. \starparen{\kwd{shadowing-import-from}
  1138. \param{package-name}
  1139. \stardown{symbol-name}} | \CR
  1140. \starparen{\kwd{import-from}
  1141. \param{package-name}
  1142. \stardown{symbol-name}} | \CR
  1143. \starparen{\kwd{export} \stardown{symbol-name}} | \CR
  1144. \starparen{\kwd{intern} \stardown{symbol-name}} | \CR
  1145. \paren{\kwd{size} \term{integer}}}
  1146. %% Removed per Pitman #2 (by X3J13 vote at May 4-5, 1994 meeting)
  1147. %% -kmp 9-May-94
  1148. %\auxbnf{symbol-name}{(\term{symbol} | \term{string})}
  1149. \endissue{DOCUMENTATION-FUNCTION-BUGS:FIX}
  1150. \label Arguments and Values::
  1151. \param{defined-package-name}---a \term{\packagenamedesignator}.
  1152. %!!!! Sandra wonders if this shouldn't be renamed to just "package".
  1153. % But be sure to see the argument named "package" below.
  1154. \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  1155. \param{package-name}---a \term{package designator}.
  1156. \endissue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  1157. \param{nickname}---a \term{\packagenamedesignator}.
  1158. \param{symbol-name}---a \term{\symbolnamedesignator}.
  1159. \param{package}---the \term{package} named \param{package-name}.
  1160. \label Description::
  1161. \macref{defpackage} creates a \term{package} as specified and returns
  1162. the \term{package}.
  1163. If \param{defined-package-name} already refers to an existing
  1164. \term{package}, the name-to-package mapping for that name is not changed.
  1165. If the new definition is at variance with the current state of that
  1166. \term{package}, the consequences are undefined; an implementation
  1167. might choose to modify the existing \term{package} to reflect the
  1168. new definition. If \param{defined-package-name} is a \term{symbol},
  1169. its \term{name} is used.
  1170. The standard \i{options} are described below.
  1171. %% Sandra: Implied by package designator above.
  1172. % In the following
  1173. % descriptions, \param{package-name} is a \term{package},
  1174. % a \term{string} or a \term{symbol} (whose \term{name} is used)
  1175. % that names a \term{package}.
  1176. \beginlist
  1177. \itemitem{\kwd{nicknames}}
  1178. The arguments to \kwd{nicknames} set the \term{package}'s nicknames to the
  1179. supplied names.
  1180. %% Sandra: Implied by {\symbolnamedesignator}.
  1181. % If \param{nicknames} are \term{symbols}, their \term{names}
  1182. % are used.
  1183. \issue{DOCUMENTATION-FUNCTION-BUGS:FIX}
  1184. \itemitem{\kwd{documentation}}
  1185. The argument to \kwd{documentation} specifies a \term{documentation string};
  1186. it is attached as a \term{documentation string} to the \term{package}.
  1187. At most one \kwd{documentation} option
  1188. can appear in a single \macref{defpackage} \term{form}.
  1189. \endissue{DOCUMENTATION-FUNCTION-BUGS:FIX}
  1190. \itemitem{\kwd{use}}
  1191. The arguments to \kwd{use} set the \term{packages} that the \term{package}
  1192. named by \param{package-name}
  1193. will inherit from. If \kwd{use} is not supplied,
  1194. \issue{MAKE-PACKAGE-USE-DEFAULT:IMPLEMENTATION-DEPENDENT}
  1195. % its value is \term{implementation-dependent}, and must be the same as that
  1196. % for \funref{make-package}.
  1197. %% Rewritten for Sandra:
  1198. it defaults to the same \term{implementation-dependent} value as \thekeyarg{use} to
  1199. \funref{make-package}.
  1200. \endissue{MAKE-PACKAGE-USE-DEFAULT:IMPLEMENTATION-DEPENDENT}
  1201. %\thepackage{common-lisp} only is inherited.
  1202. \itemitem{\kwd{shadow}}
  1203. The arguments to \kwd{shadow}, \param{symbol-names}, name \term{symbols}
  1204. that are to be created in the \term{package} being defined.
  1205. These \term{symbols} are added to the list of shadowing
  1206. \term{symbols} effectively as if by \funref{shadow}.
  1207. \itemitem{\kwd{shadowing-import-from}}
  1208. The \term{symbols} named by the argument \param{symbol-names}
  1209. are found (involving a lookup as if by \funref{find-symbol})
  1210. in the specified \param{package-name}. The resulting \term{symbols}
  1211. are \term{imported} into the \term{package} being defined, and
  1212. placed on the shadowing symbols list as if by \funref{shadowing-import}.
  1213. In no case are \term{symbols} created in any \term{package}
  1214. other than the one being defined.
  1215. \itemitem{\kwd{import-from}}
  1216. The \term{symbols} named by the argument \param{symbol-names}
  1217. are found in the \term{package} named by \param{package-name} and
  1218. they are \term{imported} into the \term{package} being defined.
  1219. In no case are \term{symbols} created in any \term{package}
  1220. other than the one being defined.
  1221. \itemitem{\kwd{export}}
  1222. The \term{symbols} named by
  1223. the argument \param{symbol-names} are found
  1224. or created in the \term{package} being defined
  1225. and \term{exported}.
  1226. The \kwd{export} option interacts
  1227. with the \kwd{use} option, since inherited \term{symbols}
  1228. can be used rather than new ones created.
  1229. The \kwd{export} option interacts
  1230. with the
  1231. \kwd{import-from} and \kwd{shadowing-import-from} options, since
  1232. \term{imported}
  1233. symbols can be used rather than new ones created.
  1234. If an argument to the \kwd{export} option is \term{accessible} as
  1235. an (inherited) \term{internal symbol} via \funref{use-package}, that the
  1236. \term{symbol} named by \param{symbol-name}
  1237. is first \term{imported} into the \term{package} being
  1238. defined, and is then \term{exported} from that \term{package}.
  1239. \itemitem{\kwd{intern}}
  1240. The \term{symbols} named by the argument \param{symbol-names}
  1241. are found or created in the \term{package} being defined.
  1242. The \kwd{intern} option interacts with the
  1243. \kwd{use} option, since inherited \term{symbols}
  1244. can be used rather than new ones created.
  1245. \itemitem{\kwd{size}}
  1246. The argument to the \kwd{size} option
  1247. declares the approximate number of \term{symbols} expected in the
  1248. \term{package}.
  1249. This is an efficiency hint only and might be ignored by an
  1250. implementation.
  1251. \endlist
  1252. The order in which the options appear in a
  1253. \macref{defpackage} form is irrelevant.
  1254. The order in which they are executed is as follows:
  1255. \beginlist
  1256. \itemitem{1.}
  1257. \kwd{shadow} and \kwd{shadowing-import-from}.
  1258. \itemitem{2.}
  1259. \kwd{use}.
  1260. \itemitem{3.}
  1261. \kwd{import-from} and \kwd{intern}.
  1262. \itemitem{4.}
  1263. \kwd{export}.
  1264. \endlist
  1265. Shadows are established first, since they might be necessary to block
  1266. spurious name conflicts when the \kwd{use}
  1267. option is processed. The \kwd{use} option is executed
  1268. next so that \kwd{intern} and \kwd{export} options can refer to normally
  1269. inherited \term{symbols}.
  1270. The \kwd{export} option is executed last so that it can refer to
  1271. \term{symbols} created by any of the other options; in
  1272. particular, \term{shadowing symbols} and
  1273. \term{imported} \term{symbols} can be made external.
  1274. \issue{COMPILE-FILE-HANDLING-OF-TOP-LEVEL-FORMS:CLARIFY}
  1275. % added top-level clarification --sjl 7 Mar 92
  1276. If a {defpackage} \term{form} appears as a \term{top level form},
  1277. all of the actions normally performed by this \term{macro}
  1278. at load time must also be performed at compile time.
  1279. \endissue{COMPILE-FILE-HANDLING-OF-TOP-LEVEL-FORMS:CLARIFY}
  1280. \label Examples::
  1281. \code
  1282. (defpackage "MY-PACKAGE"
  1283. (:nicknames "MYPKG" "MY-PKG")
  1284. (:use "COMMON-LISP")
  1285. (:shadow "CAR" "CDR")
  1286. (:shadowing-import-from "VENDOR-COMMON-LISP" "CONS")
  1287. (:import-from "VENDOR-COMMON-LISP" "GC")
  1288. (:export "EQ" "CONS" "FROBOLA")
  1289. )
  1290. (defpackage my-package
  1291. (:nicknames mypkg :MY-PKG) ; remember Common Lisp conventions for case
  1292. (:use common-lisp) ; conversion on symbols
  1293. (:shadow CAR :cdr #:cons)
  1294. (:export "CONS") ; this is the shadowed one.
  1295. )
  1296. \endcode
  1297. \label Affected By::
  1298. Existing \term{packages}.
  1299. \label Exceptional Situations::
  1300. If one of the supplied \kwd{nicknames} already
  1301. refers to an existing \term{package},
  1302. an error \oftype{package-error} is signaled.
  1303. An error \oftype{program-error} should be signaled if \kwd{size} or \kwd{documentation}
  1304. appears more than once.
  1305. Since \term{implementations} might allow extended \i{options}
  1306. an error \oftype{program-error} should be signaled
  1307. if an \i{option} is present that is not
  1308. actually supported in the host \term{implementation}.
  1309. The collection of \param{symbol-name} arguments given to the options
  1310. \kwd{shadow}, \kwd{intern},
  1311. \kwd{import-from}, and \kwd{shadowing-import-from} must
  1312. all be disjoint; additionally, the \param{symbol-name} arguments given to
  1313. \kwd{export} and \kwd{intern}
  1314. must be disjoint.
  1315. Disjoint in this context is defined as no two of the \param{symbol-names}
  1316. being \funref{string=} with each other. If either condition is
  1317. violated, an error \oftype{program-error} should be signaled.
  1318. For the \kwd{shadowing-import-from} and \kwd{import-from} options,
  1319. a \term{correctable} \term{error} \oftype{package-error}
  1320. is signaled if no \term{symbol} is
  1321. \term{accessible} in the \term{package} named by
  1322. \param{package-name} for one of the argument \param{symbol-names}.
  1323. Name conflict errors are handled by the underlying calls to
  1324. \funref{make-package}, \funref{use-package}, \funref{import}, and
  1325. \funref{export}. \Seesection\PackageConcepts.
  1326. \label See Also::
  1327. \funref{documentation},
  1328. {\secref\PackageConcepts},
  1329. {\secref\Compilation}
  1330. \label Notes::
  1331. %\macref{defpackage} does not alter the \term{current package}.
  1332. %\funref{compile-file} should treat \macref{defpackage} \term{forms}
  1333. %that are \term{top level forms} in the same way
  1334. %as it treats the other \term{package}-affecting functions.
  1335. The \kwd{intern} option is useful if an \kwd{import-from} or a
  1336. \kwd{shadowing-import-from} option in a subsequent call to \macref{defpackage}
  1337. (for some other \term{package}) expects to find
  1338. these \term{symbols} \term{accessible} but not necessarily external.
  1339. It is recommended that the entire \term{package} definition is put
  1340. in a single place, and that all the \term{package} definitions of a
  1341. program are in a single file. This file can be \term{loaded} before
  1342. \term{loading} or compiling anything else that depends on those
  1343. \term{packages}. Such a file can be read in \thepackage{common-lisp-user},
  1344. avoiding any initial state issues.
  1345. \macref{defpackage} cannot be used to create two ``mutually
  1346. recursive'' packages, such as:
  1347. \code
  1348. (defpackage my-package
  1349. (:use common-lisp your-package) ;requires your-package to exist first
  1350. (:export "MY-FUN"))
  1351. (defpackage your-package
  1352. (:use common-lisp)
  1353. (:import-from my-package "MY-FUN") ;requires my-package to exist first
  1354. (:export "MY-FUN"))
  1355. \endcode
  1356. However, nothing prevents the user from using the
  1357. \term{package}-affecting functions
  1358. such as \funref{use-package},
  1359. \funref{import}, and \funref{export} to establish such links
  1360. after a more standard use of \macref{defpackage}.
  1361. The macroexpansion of \macref{defpackage}
  1362. could usefully canonicalize the names
  1363. into \term{strings},
  1364. so that even if a source file has random \term{symbols} in the
  1365. \macref{defpackage} form, the compiled file would only contain
  1366. \term{strings}.
  1367. Frequently additional \term{implementation-dependent} options take the
  1368. form of a \term{keyword} standing by itself as an abbreviation for a list
  1369. {\tt (keyword T)}; this syntax should be properly reported as an unrecognized
  1370. option in implementations that do not support it.
  1371. \endissue{DEFPACKAGE:ADDITION}
  1372. \endcom
  1373. %%% ========== DO-ALL-SYMBOLS
  1374. %%% ========== DO-EXTERNAL-SYMBOLS
  1375. %%% ========== DO-SYMBOLS
  1376. \begincom{do-symbols, do-external-symbols, do-all-symbols}\ftype{Macro}
  1377. \issue{DECLS-AND-DOC}
  1378. \label Syntax::
  1379. \DefmacWithValuesNewline do-symbols
  1380. {\vtop{\hbox{\paren{var \brac{package \brac{result-form}}}}
  1381. \hbox{\starparam{declaration}
  1382. \star{\curly{tag | statement}}}}}
  1383. {\starparam{result}}
  1384. \DefmacWithValuesNewline do-external-symbols
  1385. {\vtop{\hbox{\paren{var \brac{package \brac{result-form}}}}
  1386. \hbox{\starparam{declaration}
  1387. \star{\curly{tag | statement}}}}}
  1388. {\starparam{result}}
  1389. \DefmacWithValuesNewline do-all-symbols
  1390. {\vtop{\hbox{\paren{var \brac{result-form}}}
  1391. \hbox{\starparam{declaration}
  1392. \star{\curly{tag | statement}}}}}
  1393. {\starparam{result}}
  1394. \label Arguments and Values::
  1395. \param{var}---a \term{variable} \term{name}; \noeval.
  1396. \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  1397. \param{package}---a \term{package designator}; \eval.
  1398. \endissue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  1399. \DefaultIn{\macref{do-symbols} and \macref{do-external-symbols}}{the \term{current package}}
  1400. \param{result-form}---a \term{form}; \evalspecial.
  1401. \Default{\nil}
  1402. \param{declaration}---a \misc{declare} \term{expression}; \noeval.
  1403. \param{tag}---a \term{go tag}; \noeval.
  1404. \param{statement}---a \term{compound form}; \evalspecial.
  1405. \param{results}---the \term{values} returned by the \param{result-form}
  1406. if a \term{normal return} occurs,
  1407. or else, if an \term{explicit return} occurs, the \term{values} that were transferred.
  1408. \label Description::
  1409. \macref{do-symbols},
  1410. \macref{do-external-symbols}, and
  1411. \macref{do-all-symbols} iterate over the \term{symbols}
  1412. of \term{packages}.
  1413. For each \term{symbol} in the set of \term{packages} chosen,
  1414. the \param{var} is bound to the \term{symbol},
  1415. and the \param{statements} in the body are executed.
  1416. When all the \term{symbols} have been processed,
  1417. \param{result-form} is evaluated and returned as the value of the macro.
  1418. %!!! Barmar: Is there a different lexical environment for each symbol??
  1419. %% 11.2.0 39
  1420. \macref{do-symbols} iterates
  1421. over the \term{symbols} \term{accessible} in
  1422. \param{package}.
  1423. \issue{DO-SYMBOLS-DUPLICATES}
  1424. \param{Statements} may execute more than once for \term{symbols}
  1425. that are inherited from multiple \term{packages}.
  1426. \endissue{DO-SYMBOLS-DUPLICATES}
  1427. %% 11.2.0 41
  1428. \macref{do-all-symbols} iterates on every \term{registered package}.
  1429. \macref{do-all-symbols} will not process every \term{symbol}
  1430. whatsoever, because a \term{symbol} not \term{accessible} in any
  1431. \term{registered package} will not be processed.
  1432. \macref{do-all-symbols} may cause a \term{symbol} that is \term{present} in
  1433. several \term{packages} to be processed more than once.
  1434. %% 11.2.0 40
  1435. \macref{do-external-symbols} iterates on the external symbols of \param{package}.
  1436. When \param{result-form} is evaluated, \param{var} is bound and has the value \nil.
  1437. \issue{DO-SYMBOLS-BLOCK-SCOPE:ENTIRE-FORM}
  1438. An \term{implicit block} named \nil\ surrounds the entire \macref{do-symbols},
  1439. \macref{do-external-symbols}, or \macref{do-all-symbols} \term{form}.
  1440. \endissue{DO-SYMBOLS-BLOCK-SCOPE:ENTIRE-FORM}
  1441. \macref{return} or \specref{return-from} may be used to terminate the
  1442. iteration prematurely.
  1443. If execution of the body affects which \term{symbols}
  1444. are contained in the set of \term{packages} over which iteration
  1445. is occurring, other than to
  1446. remove the \term{symbol}
  1447. currently the value of \param{var} by using \funref{unintern},
  1448. the consequences are undefined.
  1449. For each of these macros, the
  1450. \term{scope} of the name binding does not include any
  1451. initial value form, but the optional result forms are included.
  1452. %Better than nothing for now, I guess. -kmp 14-Feb-92
  1453. Any \param{tag} in the body is treated as with \specref{tagbody}.
  1454. \label Examples::
  1455. \code
  1456. (make-package 'temp :use nil) \EV #<PACKAGE "TEMP">
  1457. (intern "SHY" 'temp) \EV TEMP::SHY, NIL ;SHY will be an internal symbol
  1458. ;in the package TEMP
  1459. (export (intern "BOLD" 'temp) 'temp) \EV T ;BOLD will be external
  1460. (let ((lst ()))
  1461. (do-symbols (s (find-package 'temp)) (push s lst))
  1462. lst)
  1463. \EV (TEMP::SHY TEMP:BOLD)
  1464. \OV (TEMP:BOLD TEMP::SHY)
  1465. (let ((lst ()))
  1466. (do-external-symbols (s (find-package 'temp) lst) (push s lst))
  1467. lst)
  1468. \EV (TEMP:BOLD)
  1469. (let ((lst ()))
  1470. (do-all-symbols (s lst)
  1471. (when (eq (find-package 'temp) (symbol-package s)) (push s lst)))
  1472. lst)
  1473. \EV (TEMP::SHY TEMP:BOLD)
  1474. \OV (TEMP:BOLD TEMP::SHY)
  1475. \endcode
  1476. \label Side Effects:\None.
  1477. \label Affected By:\None.
  1478. \label Exceptional Situations:\None.
  1479. \label See Also::
  1480. \funref{intern},
  1481. \funref{export},
  1482. \issue{MAPPING-DESTRUCTIVE-INTERACTION:EXPLICITLY-VAGUE}
  1483. {\secref\TraversalRules}
  1484. \endissue{MAPPING-DESTRUCTIVE-INTERACTION:EXPLICITLY-VAGUE}
  1485. \label Notes:\None.
  1486. \endissue{DECLS-AND-DOC}
  1487. \endcom
  1488. %%% ========== INTERN
  1489. \begincom{intern}\ftype{Function}
  1490. \label Syntax::
  1491. \DefunWithValues intern {string {\opt} package} {symbol, status}
  1492. \label Arguments and Values::
  1493. \param{string}---a \term{string}.
  1494. \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  1495. \param{package}---a \term{package designator}.
  1496. \endissue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  1497. \Default{the \term{current package}}
  1498. \param{symbol}---a \term{symbol}.
  1499. \param{status}---one of \kwd{inherited}, \kwd{external}, \kwd{internal}, or \nil.
  1500. \label Description::
  1501. %% 11.2.0 20
  1502. \funref{intern} enters a \term{symbol} named \param{string} into \param{package}.
  1503. If a \term{symbol} whose name is the same as \param{string}
  1504. is already \term{accessible} in \param{package}, it is returned.
  1505. If no such \term{symbol} is \term{accessible} in \param{package},
  1506. a new \term{symbol} with the given name is created
  1507. and entered into \param{package} as an \term{internal symbol},
  1508. or as an \term{external symbol} if the \param{package} is \thepackage{keyword};
  1509. \param{package} becomes the \term{home package} of the created \term{symbol}.
  1510. %% 11.2.0 21
  1511. %% 11.2.0 22
  1512. The first value returned by \funref{intern}, \param{symbol},
  1513. is the \term{symbol} that was found or
  1514. created.
  1515. %% Sandra thinks, and I agree, that this is confused and doesn't belong here. -kmp 14-Feb-92
  1516. % \issue{CHARACTER-PROPOSAL:2-1-1}
  1517. % It is \term{implementation-dependent}
  1518. % %but consistent with \funref{read},
  1519. % which \term{implementation-defined} \term{attributes} are removed.
  1520. % \endissue{CHARACTER-PROPOSAL:2-1-1}
  1521. The meaning of the \term{secondary value}, \param{status}, is as follows:
  1522. \beginlist
  1523. \itemitem{\kwd{internal}}
  1524. The \term{symbol} was found
  1525. and is
  1526. %directly
  1527. \term{present} in \param{package} as an \term{internal symbol}.
  1528. \itemitem{\kwd{external}}
  1529. The \term{symbol} was found
  1530. and is
  1531. %directly
  1532. \term{present} as an \term{external symbol}.
  1533. \itemitem{\kwd{inherited}}
  1534. The \term{symbol} was found
  1535. and is inherited via \funref{use-package}
  1536. (which implies that the \term{symbol} is internal).
  1537. \itemitem{\nil}
  1538. No pre-existing \term{symbol} was found,
  1539. so one was created.
  1540. %% 10.3.0 6
  1541. %% On Sandra's advice, I stole this paragraph from MAKE-SYMBOL with mods to make
  1542. %% it fit better here. -kmp 14-Feb-92
  1543. It is \term{implementation-dependent} whether the \term{string}
  1544. that becomes the new \term{symbol}'s \term{name} is the given
  1545. \param{string} or a copy of it. Once a \term{string}
  1546. has been given as the \param{string} \term{argument} to
  1547. \term{intern} in this situation where a new \term{symbol} is created,
  1548. the consequences are undefined if a
  1549. subsequent attempt is made to alter that \term{string}.
  1550. \endlist
  1551. \label Examples::
  1552. \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  1553. \code
  1554. (in-package "COMMON-LISP-USER") \EV #<PACKAGE "COMMON-LISP-USER">
  1555. (intern "Never-Before") \EV |Never-Before|, NIL
  1556. (intern "Never-Before") \EV |Never-Before|, :INTERNAL
  1557. (intern "NEVER-BEFORE" "KEYWORD") \EV :NEVER-BEFORE, NIL
  1558. (intern "NEVER-BEFORE" "KEYWORD") \EV :NEVER-BEFORE, :EXTERNAL
  1559. \endcode
  1560. \endissue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  1561. \label Side Effects:\None.
  1562. \label Affected By:\None.
  1563. \label Exceptional Situations:\None.
  1564. \label See Also::
  1565. \funref{find-symbol},
  1566. \funref{read},
  1567. \typeref{symbol},
  1568. \funref{unintern},
  1569. {\secref\SymbolTokens}
  1570. \label Notes::
  1571. %% 11.0.0 51
  1572. \funref{intern} does not need to do any name conflict checking
  1573. because it never creates a new \term{symbol}
  1574. if there is already an \term{accessible} \term{symbol} with the name given.
  1575. \endcom
  1576. %%% ========== PACKAGE-NAME
  1577. \begincom{package-name}\ftype{Function}
  1578. \label Syntax::
  1579. \DefunWithValues package-name {package} {name}
  1580. \label Arguments and Values::
  1581. \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  1582. \param{package}---a \term{package designator}.
  1583. \endissue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  1584. \param{name}---a \term{string}
  1585. \issue{PACKAGE-DELETION:NEW-FUNCTION}
  1586. or \nil.
  1587. \endissue{PACKAGE-DELETION:NEW-FUNCTION}
  1588. \label Description::
  1589. %% 11.2.0 13
  1590. \funref{package-name} returns the \term{string} that names \param{package},
  1591. \issue{PACKAGE-DELETION:NEW-FUNCTION}
  1592. or \nil\ if the \param{package} \term{designator}
  1593. is a \term{package} \term{object} that has no name (\seefun{delete-package}).
  1594. \endissue{PACKAGE-DELETION:NEW-FUNCTION}
  1595. \label Examples::
  1596. \code
  1597. (in-package "COMMON-LISP-USER") \EV #<PACKAGE "COMMON-LISP-USER">
  1598. (package-name *package*) \EV "COMMON-LISP-USER"
  1599. (package-name (symbol-package :test)) \EV "KEYWORD"
  1600. (package-name (find-package 'common-lisp)) \EV "COMMON-LISP"
  1601. \endcode
  1602. \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  1603. \code
  1604. (defvar *foo-package* (make-package "FOO"))
  1605. (rename-package "FOO" "FOO0")
  1606. (package-name *foo-package*) \EV "FOO0"
  1607. \endcode
  1608. \endissue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  1609. \label Side Effects:\None.
  1610. \label Affected By:\None.
  1611. \label Exceptional Situations::
  1612. \Shouldchecktype{package}{a \term{package designator}}
  1613. \label See Also:\None.
  1614. \label Notes:\None.
  1615. \endcom
  1616. %%% ========== PACKAGE-NICKNAMES
  1617. \begincom{package-nicknames}\ftype{Function}
  1618. \label Syntax::
  1619. \DefunWithValues package-nicknames {package} {nicknames}
  1620. \label Arguments and Values::
  1621. \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  1622. \param{package}---a \term{package designator}.
  1623. \endissue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  1624. \param{nicknames}---a \term{list} of \term{strings}.
  1625. \label Description::
  1626. %% 11.2.0 14
  1627. Returns the \term{list} of nickname \term{strings}
  1628. for \param{package}, not including the name of \param{package}.
  1629. %!!! Can it be "a" list instead of "the" list? Must it be cached? -kmp 25-Apr-91
  1630. \label Examples::
  1631. \code
  1632. (package-nicknames (make-package 'temporary
  1633. :nicknames '("TEMP" "temp")))
  1634. \EV ("temp" "TEMP")
  1635. \endcode
  1636. \label Side Effects:\None.
  1637. \label Affected By:\None.
  1638. \label Exceptional Situations::
  1639. \Shouldchecktype{package}{a \term{package designator}}
  1640. \label See Also:\None.
  1641. \label Notes:\None.
  1642. \endcom
  1643. %%% ========== PACKAGE-SHADOWING-SYMBOLS
  1644. \begincom{package-shadowing-symbols}\ftype{Function}
  1645. \label Syntax::
  1646. \DefunWithValues package-shadowing-symbols {package} {symbols}
  1647. \label Arguments and Values::
  1648. % Issue PACKAGE-FUNCTION-CONSISTENCY is silent on whether a "package designator"
  1649. % is really the right thing here, but KAB, Sandra, and KMP agree that this is what
  1650. % was probably intended.
  1651. \param{package}---a \term{package designator}.
  1652. \param{symbols}---a \term{list} of \term{symbols}.
  1653. \label Description::
  1654. %% 11.2.0 18
  1655. %% Sandra: Must this list be freshly consed?
  1656. %Creates
  1657. Returns a \term{list} of \term{symbols} that have been declared
  1658. as \term{shadowing symbols} in \param{package} by \funref{shadow}
  1659. or \funref{shadowing-import} (or the equivalent \macref{defpackage} options).
  1660. All \term{symbols} on this \term{list} are \term{present} in \param{package}.
  1661. \label Examples::
  1662. \code
  1663. (package-shadowing-symbols (make-package 'temp)) \EV ()
  1664. (shadow 'cdr 'temp) \EV T
  1665. (package-shadowing-symbols 'temp) \EV (TEMP::CDR)
  1666. (intern "PILL" 'temp) \EV TEMP::PILL, NIL
  1667. (shadowing-import 'pill 'temp) \EV T
  1668. (package-shadowing-symbols 'temp) \EV (PILL TEMP::CDR)
  1669. \endcode
  1670. \label Side Effects:\None.
  1671. \label Affected By:\None.
  1672. \label Exceptional Situations::
  1673. \Shouldchecktype{package}{a \term{package designator}}
  1674. \label See Also::
  1675. \funref{shadow},
  1676. \funref{shadowing-import}
  1677. \label Notes::
  1678. %Is the list fresh every time, or can it be cached? -kmp 25-Apr-91
  1679. %Sandra thinks it might be, so I added this not. -kmp 13-Feb-92
  1680. Whether the list of \param{symbols} is \term{fresh} is \term{implementation-dependent}.
  1681. \endcom
  1682. %%% ========== PACKAGE-USE-LIST
  1683. \begincom{package-use-list}\ftype{Function}
  1684. \label Syntax::
  1685. \DefunWithValues package-use-list {package} {use-list}
  1686. \label Arguments and Values::
  1687. \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  1688. \param{package}---a \term{package designator}.
  1689. \endissue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  1690. \param{use-list}---a \term{list} of \term{package} \term{objects}.
  1691. \label Description::
  1692. %% 11.2.0 16
  1693. %!!! Is the word "other" really needed here? -kmp 25-Apr-91
  1694. Returns a \term{list} of other \term{packages} used by \param{package}.
  1695. \label Examples::
  1696. \code
  1697. (package-use-list (make-package 'temp)) \EV (#<PACKAGE "COMMON-LISP">)
  1698. (use-package 'common-lisp-user 'temp) \EV T
  1699. (package-use-list 'temp) \EV (#<PACKAGE "COMMON-LISP"> #<PACKAGE "COMMON-LISP-USER">)
  1700. \endcode
  1701. \label Side Effects:\None.
  1702. \label Affected By:\None.
  1703. \label Exceptional Situations::
  1704. \Shouldchecktype{package}{a \term{package designator}}
  1705. \label See Also::
  1706. \funref{use-package},
  1707. \funref{unuse-package}
  1708. \label Notes:\None.
  1709. \endcom
  1710. %%% ========== PACKAGE-USED-BY-LIST
  1711. \begincom{package-used-by-list}\ftype{Function}
  1712. \label Syntax::
  1713. \DefunWithValues package-used-by-list {package} {used-by-list}
  1714. \label Arguments and Values::
  1715. \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  1716. \param{package}---a \term{package designator}.
  1717. \endissue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE}
  1718. \param{used-by-list}---a \term{list} of \term{package} \term{objects}.
  1719. \label Description::
  1720. %% 11.2.0 17
  1721. \funref{package-used-by-list} returns a \term{list}
  1722. of other \term{packages} that use \param{package}.
  1723. \label Examples::
  1724. \code
  1725. (package-used-by-list (make-package 'temp)) \EV ()
  1726. (make-package 'trash :use '(temp)) \EV #<PACKAGE "TRASH">
  1727. (package-used-by-list 'temp) \EV (#<PACKAGE "TRASH">)
  1728. \endcode
  1729. \label Side Effects:\None.
  1730. \label Affected By:\None.
  1731. \label Exceptional Situations::
  1732. \Shouldchecktype{package}{a \term{package}}
  1733. \label See Also::
  1734. \funref{use-package},
  1735. \funref{unuse-package}
  1736. \label Notes:\None.
  1737. \endcom
  1738. %%% ========== PACKAGEP
  1739. \begincom{packagep}\ftype{Function}
  1740. \label Syntax::
  1741. \DefunWithValues packagep {object} {generalized-boolean}
  1742. \label Arguments and Values::
  1743. \param{object}---an \term{object}.
  1744. \param{generalized-boolean}---a \term{generalized boolean}.
  1745. \label Description::
  1746. %% 6.2.2 25
  1747. \TypePredicate{object}{package}
  1748. \label Examples::
  1749. \code
  1750. (packagep *package*) \EV \term{true}
  1751. (packagep 'common-lisp) \EV \term{false}
  1752. (packagep (find-package 'common-lisp)) \EV \term{true}
  1753. \endcode
  1754. \label Side Effects:\None.
  1755. \label Affected By:\None.
  1756. \label Exceptional Situations:\None!
  1757. \label See Also:\None.
  1758. \label Notes::
  1759. \code
  1760. (packagep \param{object}) \EQ (typep \param{object} 'package)
  1761. \endcode
  1762. \endcom
  1763. %%% ========== *PACKAGE*
  1764. \begincom{*package*}\ftype{Variable}
  1765. \label Value Type::
  1766. a \term{package} \term{object}.
  1767. \label Initial Value::
  1768. \thepackage{common-lisp-user}.
  1769. %% 11.2.0 6
  1770. %% 11.0.0 23
  1771. \label Description::
  1772. Whatever \term{package} \term{object} is currently
  1773. \thevalueof{*package*} is referred to as the \term{current package}.
  1774. \label Examples::
  1775. \code
  1776. (in-package "COMMON-LISP-USER") \EV #<PACKAGE "COMMON-LISP-USER">
  1777. *package* \EV #<PACKAGE "COMMON-LISP-USER">
  1778. (make-package "SAMPLE-PACKAGE" :use '("COMMON-LISP"))
  1779. \EV #<PACKAGE "SAMPLE-PACKAGE">
  1780. (list
  1781. (symbol-package
  1782. (let ((*package* (find-package 'sample-package)))
  1783. (setq *some-symbol* (read-from-string "just-testing"))))
  1784. *package*)
  1785. \EV (#<PACKAGE "SAMPLE-PACKAGE"> #<PACKAGE "COMMON-LISP-USER">)
  1786. (list (symbol-package (read-from-string "just-testing"))
  1787. *package*)
  1788. \EV (#<PACKAGE "COMMON-LISP-USER"> #<PACKAGE "COMMON-LISP-USER">)
  1789. (eq 'foo (intern "FOO")) \EV \term{true}
  1790. (eq 'foo (let ((*package* (find-package 'sample-package)))
  1791. (intern "FOO")))
  1792. \EV \term{false}
  1793. \endcode
  1794. \label Affected By::
  1795. \funref{load},
  1796. \funref{compile-file},
  1797. \funref{in-package}
  1798. \label See Also::
  1799. \funref{compile-file},
  1800. \macref{in-package},
  1801. \funref{load},
  1802. \funref{package}
  1803. \label Notes:\None.
  1804. \endcom
  1805. %-------------------- Package Errors --------------------
  1806. \begincom{package-error}\ftype{Condition Type}
  1807. \label Class Precedence List::
  1808. \typeref{package-error},
  1809. \typeref{error},
  1810. \typeref{serious-condition},
  1811. \typeref{condition},
  1812. \typeref{t}
  1813. \label Description::
  1814. \Thetype{package-error} consists of \term{error} \term{conditions}
  1815. related to operations on \term{packages}.
  1816. The offending \term{package} (or \term{package} \term{name})
  1817. is initialized by \theinitkeyarg{package} to \funref{make-condition},
  1818. and is \term{accessed} by \thefunction{package-error-package}.
  1819. \label See Also::
  1820. \funref{package-error-package},
  1821. {\secref\Conditions}
  1822. \endcom%{package-error}\ftype{Condition Type}
  1823. %%% ========== PACKAGE-ERROR-PACKAGE
  1824. \begincom{package-error-package}\ftype{Function}
  1825. \label Syntax::
  1826. \DefunWithValues package-error-package {condition} {package}
  1827. \label Arguments and Values::
  1828. \param{condition}---a \term{condition} \oftype{package-error}.
  1829. \param{package}---a \term{package designator}.
  1830. \label Description::
  1831. Returns a \term{designator} for the offending \term{package}
  1832. in the \term{situation} represented by the \param{condition}.
  1833. \label Examples::
  1834. \code
  1835. (package-error-package
  1836. (make-condition 'package-error
  1837. :package (find-package "COMMON-LISP")))
  1838. \EV #<Package "COMMON-LISP">
  1839. \endcode
  1840. \label Side Effects:\None.
  1841. \label Affected By:\None.
  1842. \label Exceptional Situations:\None.
  1843. \label See Also::
  1844. \typeref{package-error}
  1845. \label Notes:\None.
  1846. %% This shouldn't be needed.
  1847. %It is an error to use \macref{setf} with \funref{package-error-package}.
  1848. \endcom