concept-packages.tex 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. % -*- Mode: TeX -*-
  2. %!!! Barmar: Tell me why multiple packags are needed.
  3. % e.g., to prevent variable and function conflicts.
  4. \beginsubSection{Introduction to Packages}
  5. %% 10.0.0 7
  6. %% 11.0.0 4
  7. A \newterm{package} establishes a mapping from names to \term{symbols}.
  8. At any given time, one \term{package} is current.
  9. The \newterm{current package} is the one that is \thevalueof{*package*}.
  10. When using the \term{Lisp reader},
  11. it is possible to refer to \term{symbols} in \term{packages}
  12. other than the current one through the use of \term{package prefixes} in the
  13. printed representation of the \term{symbol}.
  14. %% 11.2.0 5
  15. \Thenextfigure\ lists some \term{defined names} that are applicable
  16. to \term{packages}.
  17. %Shouldn't be needed. This info is all explicit now. -kmp 29-Apr-91
  18. % For the \term{operators} listed here, all optional arguments named
  19. % \param{package} default to the \term{current package}.
  20. Where an \term{operator}
  21. takes an argument that is either a \term{symbol} or a \term{list}
  22. of \term{symbols},
  23. an argument of \nil\ is treated as an empty \term{list} of \term{symbols}.
  24. Any \param{package} argument may be either a \term{string}, a \term{symbol}, or
  25. a \term{package}. If a \term{symbol} is supplied, its name will be used
  26. as the \term{package} name.
  27. \issue{REQUIRE-PATHNAME-DEFAULTS:ELIMINATE}
  28. % \funref{provide}, \funref{require}, and \varref{*modules*} will
  29. % be removed from this table (and the language).
  30. %PROVIDE and REQUIRE need to be removed, right? -kmp 29-Apr-91
  31. %Nope! -kmp 13-Feb-92
  32. \displaythree{Some Defined Names related to Packages}{
  33. *modules*&import&provide\cr
  34. *package*&in-package&rename-package\cr
  35. defpackage&intern&require\cr
  36. do-all-symbols&list-all-packages&shadow\cr
  37. do-external-symbols&make-package&shadowing-import\cr
  38. do-symbols&package-name&unexport\cr
  39. export&package-nicknames&unintern\cr
  40. find-all-symbols&package-shadowing-symbols&unuse-package\cr
  41. find-package&package-use-list&use-package\cr
  42. find-symbol&package-used-by-list&\cr
  43. }
  44. \endissue{REQUIRE-PATHNAME-DEFAULTS:ELIMINATE}
  45. \beginsubsubsection{Package Names and Nicknames}
  46. %% 11.0.0 19
  47. Each \term{package} has a \term{name} (a \term{string}) and perhaps some \term{nicknames}
  48. (also \term{strings}).
  49. These are assigned when the \term{package} is created and can be changed later.
  50. %% 11.0.0 20
  51. There is a single namespace for \term{packages}.
  52. \Thefunction{find-package} translates a package
  53. \term{name} or \term{nickname} into the associated \term{package}.
  54. \Thefunction{package-name} returns the \term{name} of a \term{package}.
  55. \Thefunction{package-nicknames} returns
  56. a \term{list} of all \term{nicknames} for a \term{package}.
  57. \funref{rename-package} removes a \term{package}'s
  58. current \term{name} and \term{nicknames} and replaces them with new ones
  59. specified by the caller.
  60. \endsubsubsection%{Package Names and Nicknames}
  61. \beginsubsubsection{Symbols in a Package}
  62. \beginsubsubsubsection{Internal and External Symbols}
  63. %% 11.0.0 5
  64. The mappings in a \term{package} are divided into two classes, external and internal.
  65. The \term{symbols} targeted by these different mappings
  66. are called \term{external symbols} and \term{internal symbols}\idxterm{internal symbol} of the
  67. \term{package}. Within a \term{package}, a name refers to one
  68. \term{symbol} or to none; if it does refer
  69. to a \term{symbol}, then it is either external or internal in that
  70. \term{package}, but not both.
  71. %% 11.0.0 6
  72. \newtermidx{External symbols}{external symbol}
  73. are part of the package's public interface to other \term{packages}.
  74. \term{Symbols} become \term{external symbols} of a given
  75. \term{package} if they have been \term{exported} from that \term{package}.
  76. %% 11.0.0 7
  77. A \term{symbol} has the same \term{name} no matter what \term{package}
  78. it is \term{present} in, but it might be an \term{external symbol} of some \term{packages}
  79. and an \term{internal symbol} of others.
  80. \endsubsubsubsection%{Internal and External Symbols}
  81. \beginsubsubsubsection{Package Inheritance}
  82. %% 11.0.0 9
  83. \term{Packages} can be built up in layers. From one point of view,
  84. a \term{package} is a single collection
  85. of mappings from \term{strings} into \term{internal symbols} and
  86. \term{external symbols}.
  87. However, some of these mappings might be established within the \term{package}
  88. itself, while other mappings are inherited from other \term{packages}
  89. via \funref{use-package}.
  90. A \term{symbol} is said to be \newterm{present} in a \term{package}
  91. if the mapping is in the \term{package} itself and is
  92. not inherited from somewhere else.
  93. %% 11.4.0
  94. There is no way to inherit the \term{internal symbols} of another \term{package};
  95. to refer to an \term{internal symbol} using the \term{Lisp reader},
  96. a \term{package} containing the \term{symbol}
  97. must be made to be the \term{current package},
  98. a \term{package prefix} must be used,
  99. or the \term{symbol} must be \term{imported} into the \term{current package}.
  100. \endsubsubsubsection%{Package Inheritance}
  101. \beginsubsubsubsection{Accessibility of Symbols in a Package}
  102. A \term{symbol} becomes \newterm{accessible} in a \term{package}
  103. if that is its \term{home package} when it is created,
  104. or if it is \term{imported} into that \term{package},
  105. or by inheritance via \funref{use-package}.
  106. If a \term{symbol} is \term{accessible} in a \term{package},
  107. it can be referred to when using the \term{Lisp reader}
  108. without a \term{package prefix} when that \term{package} is the \term{current package},
  109. regardless of whether it is \term{present} or inherited.
  110. %???Move the following to \secref\Syntax???
  111. %A \term{symbol} will not necessarily always have the same
  112. %printed representation because the way \term{symbols} are printed
  113. %depends on whether or not they are \term{accessible} in the \term{current package}.
  114. %% 11.0.0 35
  115. \term{Symbols} from one \term{package} can be made \term{accessible}
  116. in another \term{package} in two ways.
  117. %% 11.0.0 36
  118. \beginlist
  119. \itemitem{--}
  120. Any individual \term{symbol} can be added to a \term{package} by use
  121. of \funref{import}. After the call to \funref{import} the
  122. \term{symbol} is \term{present} in the importing \term{package}.
  123. The status of the \term{symbol} in the \term{package}
  124. it came from (if any) is unchanged, and the \term{home package} for
  125. this \term{symbol} is unchanged.
  126. Once \term{imported}, a \term{symbol} is \term{present} in the
  127. importing \term{package}
  128. and can be removed only by calling \funref{unintern}.
  129. %% 11.4.0 4
  130. A \term{symbol} is \term{shadowed}\meaning{3} by another \term{symbol}
  131. in some \term{package} if the first \term{symbol} would be \term{accessible}
  132. by inheritance if not for the presence of the second \term{symbol}.
  133. See \funref{shadowing-import}.
  134. %% 11.4.0 39
  135. %% 11.4.0 40
  136. \itemitem{--}
  137. The second mechanism for making \term{symbols} from one \term{package}
  138. \term{accessible} in another is provided by \funref{use-package}.
  139. All of the \term{external symbols} of the used \term{package} are inherited
  140. by the using \term{package}.
  141. \Thefunction{unuse-package} undoes the effects of a previous \funref{use-package}.
  142. \endlist
  143. \endsubsubsubsection%{Accessibility of Symbols in a Package}
  144. \beginsubsubsubsection{Locating a Symbol in a Package}
  145. %% 11.4.0 8
  146. When a \term{symbol} is to be located in a given \term{package}
  147. the following occurs:
  148. \beginlist
  149. \itemitem{--} The \term{external symbols} and \term{internal symbols} of the
  150. \term{package} are searched for the \term{symbol}.
  151. \itemitem{--} The \term{external symbols} of the used \term{packages} are
  152. searched
  153. in some unspecified order. The
  154. order does not matter; see the rules for handling name
  155. conflicts listed below.
  156. \endlist
  157. \endsubsubsubsection%{Locating a Symbol in a Package}
  158. \beginsubsubsubsection{Prevention of Name Conflicts in Packages}
  159. %% 11.0.0 46
  160. Within one \term{package}, any particular name can refer to at most one
  161. \term{symbol}. A name conflict is said to occur when there would be more than
  162. one candidate \term{symbol}. Any time a name conflict is about to occur,
  163. a \term{correctable} \term{error} is signaled.
  164. The following rules apply to name conflicts:
  165. %% 11.0.0 47
  166. \beginlist
  167. %% 11.0.0 49
  168. \itemitem{--}
  169. Name conflicts are detected when they become possible, that is, when the
  170. package structure is altered. Name
  171. conflicts are not checked during every name lookup.
  172. \itemitem{--}
  173. If the \term{same} \term{symbol} is \term{accessible} to a \term{package}
  174. through more than one path, there is no name conflict.
  175. A \term{symbol} cannot conflict with itself.
  176. Name conflicts occur only between \term{distinct} \term{symbols} with
  177. the same name (under \funref{string=}).
  178. %% 11.0.0 48
  179. \itemitem{--} Every \term{package} has a list of shadowing \term{symbols}.
  180. A shadowing \term{symbol} takes precedence over any other \term{symbol} of
  181. the same name that would otherwise be \term{accessible} in the \term{package}.
  182. A name conflict involving a shadowing symbol is always resolved in favor of
  183. the shadowing \term{symbol}, without signaling an error (except for one
  184. exception involving \funref{import}).
  185. See \funref{shadow} and \funref{shadowing-import}.
  186. %% 11.0.0 50
  187. \itemitem{--}
  188. The functions \funref{use-package}, \funref{import}, and
  189. \funref{export} check for name conflicts.
  190. %% 11.0.0 52
  191. \itemitem{--}
  192. \funref{shadow} and \funref{shadowing-import}
  193. never signal a name-conflict error.
  194. %% 11.0.0 53
  195. \itemitem{--}
  196. % \funref{unuse-package}, \funref{unexport}, and \funref{unintern}
  197. % (when the \term{symbol} being uninterned is not a \term{shadowing symbol})
  198. % do not need to do any name-conflict checking.
  199. %% Rewording for JonL:
  200. \funref{unuse-package} and \funref{unexport}
  201. do not need to do any name-conflict checking.
  202. \funref{unintern} does name-conflict checking only when a \term{symbol}
  203. being \term{uninterned} is a \term{shadowing symbol}\idxterm{shadowing symbol}.
  204. %% 11.0.0 54
  205. \itemitem{--}
  206. Giving a shadowing symbol to \funref{unintern}
  207. can uncover a name conflict that had
  208. previously been resolved by the shadowing.
  209. %% 11.0.0 55
  210. %\itemitem{--}
  211. %Aborting from a name-conflict error leaves the original \term{symbol}
  212. %\term{accessible}.
  213. \itemitem{--}
  214. Package functions signal name-conflict errors \oftype{package-error} before making any
  215. change to the package structure. When multiple changes are to be made,
  216. it is
  217. permissible for the implementation to process each change separately.
  218. For example, when \funref{export} is given a
  219. \term{list} of
  220. \term{symbols},
  221. aborting from a name
  222. conflict caused by the second \term{symbol}
  223. in the \term{list} might still export the
  224. first \term{symbol} in the \term{list}.
  225. However, a name-conflict error caused by \funref{export}
  226. of a single \term{symbol} will be signaled before
  227. that \term{symbol}'s \term{accessibility} in any \term{package} is changed.
  228. %% 11.0.0 56
  229. \itemitem{--}
  230. Continuing from a name-conflict error must offer the user a chance to
  231. resolve the name conflict in favor of either of the candidates. The
  232. \term{package}
  233. structure should be altered to reflect the resolution of the
  234. name conflict, via \funref{shadowing-import},
  235. \funref{unintern},
  236. %!!! Barmar: The next two bullets don't mention "unexport".
  237. or \funref{unexport}.
  238. %% 11.0.0 57
  239. \itemitem{--}
  240. A name conflict in \funref{use-package} between a \term{symbol}
  241. %directly
  242. \term{present} in the using \term{package} and an \term{external symbol} of the used
  243. \term{package} is resolved in favor of the first \term{symbol} by making it a
  244. shadowing \term{symbol}, or in favor of the second \term{symbol} by uninterning
  245. the first \term{symbol} from the using \term{package}.
  246. %% 11.0.0 60
  247. \itemitem{--}
  248. A name conflict in \funref{export} or \funref{unintern}
  249. due to a \term{package}'s inheriting two \term{distinct} \term{symbols}
  250. with the \term{same} \term{name} (under \funref{string=})
  251. from two other \term{packages} can be resolved in
  252. favor of either \term{symbol} by importing it into the using
  253. \term{package} and making it a \term{shadowing symbol}\idxterm{shadowing symbol},
  254. just as with \funref{use-package}.
  255. \endlist
  256. \endsubsubsubsection%{Prevention of Name Conflicts in Packages}
  257. \endsubsubsection%{Symbols in a Package}
  258. \endsubSection%{Introduction to Packages}
  259. \beginsubSection{Standardized Packages}
  260. %% 11.6.0 1
  261. This section describes the \term{packages} that are available
  262. in every \term{conforming implementation}. A summary of the
  263. \term{names} and \term{nicknames} of those \term{standardized} \term{packages}
  264. is given in \thenextfigure.
  265. \tablefigtwo{Standardized Package Names}{Name}{Nicknames}{
  266. \packref{common-lisp}&\packref{cl}\cr
  267. \packref{common-lisp-user}&\packref{cl-user}\cr
  268. \packref{keyword}&\i{none}\cr
  269. }
  270. \issue{LISP-PACKAGE-NAME:COMMON-LISP}
  271. %% 11.6.0 2
  272. % Discussion of package LISP and USER removed. -kmp 15-Feb-92
  273. \endissue{LISP-PACKAGE-NAME:COMMON-LISP}
  274. \issue{PACKAGE-CLUTTER:REDUCE}
  275. %% 11.6.0 5
  276. % Discussion of the CLtL1 package named SYSTEM removed.
  277. \endissue{PACKAGE-CLUTTER:REDUCE}
  278. \beginsubsubsection{The COMMON-LISP Package}
  279. \idxpackref{common-lisp}\idxpackref{cl}
  280. \issue{LISP-PACKAGE-NAME:COMMON-LISP}
  281. \Thepackage{common-lisp} contains the primitives of the \clisp\ system as
  282. defined by this specification. Its \term{external} \term{symbols} include
  283. all of the \term{defined names} (except for \term{defined names} in
  284. \thepackage{keyword}) that are present in the \clisp\ system,
  285. such as \funref{car}, \funref{cdr}, \varref{*package*}, etc.
  286. \Thepackage{common-lisp} has the \term{nickname} \packref{cl}.
  287. \issue{PACKAGE-CLUTTER:REDUCE}
  288. \Thepackage{common-lisp} has as \term{external} \term{symbols} those
  289. symbols enumerated in the figures in \secref\CLsymbols, and no others.
  290. These \term{external} \term{symbols} are \term{present} in \thepackage{common-lisp}
  291. but their \term{home package} need not be \thepackage{common-lisp}.
  292. For example, the symbol \f{HELP} cannot be an \term{external symbol} of
  293. \thepackage{common-lisp} because it is not mentioned in \secref\CLsymbols.
  294. In contrast, the \term{symbol} \misc{variable}
  295. must be an \term{external symbol} of \thepackage{common-lisp}
  296. even though it has no definition
  297. because it is listed in that section
  298. (to support its use as a valid second \term{argument} to \thefunction{documentation}).
  299. % Moved this sentence out of previous paragraph. --sjl 7 Mar 92
  300. \Thepackage{common-lisp} can have additional \term{internal symbols}.
  301. \endissue{PACKAGE-CLUTTER:REDUCE}
  302. \beginsubsubsubsection{Constraints on the COMMON-LISP Package for Conforming Implementations}
  303. \issue{PACKAGE-CLUTTER:REDUCE}
  304. In a \term{conforming implementation},
  305. an \term{external} \term{symbol} of \thepackage{common-lisp} can have
  306. a \term{function}, \term{macro}, or \term{special operator} definition,
  307. %top level value ???
  308. a \term{global variable} definition
  309. (or other status as a \term{dynamic variable}
  310. due to a \declref{special} \term{proclamation}),
  311. or a \term{type} definition
  312. only if explicitly permitted in this standard.
  313. %% That's the definition of a conforming implementation. -kmp
  314. %that is, a \term{conforming program} may assume that this is true.
  315. For example,
  316. \funref{fboundp} \term{yields} \term{false}
  317. for any \term{external symbol} of \thepackage{common-lisp}
  318. that is not the \term{name} of a \term{standardized}
  319. \term{function}, \term{macro} or \term{special operator},
  320. and
  321. \funref{boundp} returns \term{false}
  322. for any \term{external symbol} of \thepackage{common-lisp}
  323. that is not the \term{name} of a \term{standardized} \term{global variable}.
  324. It also follows that
  325. \term{conforming programs} can use \term{external symbols} of \thepackage{common-lisp}
  326. as the \term{names} of local \term{lexical variables}
  327. with confidence that those \term{names} have not been \term{proclaimed} \declref{special}
  328. by the \term{implementation}
  329. unless those \term{symbols} are
  330. \term{names} of \term{standardized} \term{global variables}.
  331. %%KMP: Initially or for all times? -kmp 2-Jan-91
  332. %%Sandra: The intent was to cover properties put there by the implementation, not the user.
  333. %%KMP: I double-checked the issues, and that seems to be right.
  334. % No \term{external symbols} of \thepackage{common-lisp}
  335. % can have \term{properties} with \term{property indicators}
  336. % that are either \term{external symbols} of any \term{standardized} \term{packages}
  337. % or otherwise \term{accessible} in \thepackage{common-lisp-user}.
  338. %% Rewritten. -kmp 15-Feb-92
  339. A \term{conforming implementation} must not place any \term{property} on
  340. an \term{external symbol} of \thepackage{common-lisp} using a \term{property indicator}
  341. that is either an \term{external symbol} of any \term{standardized} \term{package}
  342. or a \term{symbol} that is otherwise \term{accessible} in \thepackage{common-lisp-user}.
  343. %Valid programs
  344. % can assume that the conformal Lisp implementation will not
  345. % have prohibited properties. The proposal LISP-SYMBOL-REDEFINITION
  346. % addresses the converse; that is, what user programs are allowed
  347. % to do.
  348. \endissue{PACKAGE-CLUTTER:REDUCE}
  349. \endsubsubsubsection%{Constraints on the COMMON-LISP Package for Conforming Implementations}
  350. \beginsubsubsubsection{Constraints on the COMMON-LISP Package for Conforming Programs}
  351. \idxtext{redefinition}
  352. \issue{LISP-SYMBOL-REDEFINITION:MAR89-X3J13}
  353. Except where explicitly allowed, the consequences are undefined if any
  354. of the following actions are performed on an \term{external symbol}
  355. of \thepackage{common-lisp}:
  356. \beginlist
  357. \itemitem{1.} \term{Binding} or altering its value (lexically or dynamically).
  358. (Some exceptions are noted below.)
  359. \itemitem{2.} Defining,
  360. \issue{LISP-SYMBOL-REDEFINITION-AGAIN:MORE-FIXES}
  361. undefining,
  362. \endissue{LISP-SYMBOL-REDEFINITION-AGAIN:MORE-FIXES}
  363. or \term{binding} it as a \term{function}.
  364. (Some exceptions are noted below.)
  365. \itemitem{3.} Defining,
  366. \issue{LISP-SYMBOL-REDEFINITION-AGAIN:MORE-FIXES}
  367. undefining,
  368. \endissue{LISP-SYMBOL-REDEFINITION-AGAIN:MORE-FIXES}
  369. or \term{binding} it as a \term{macro}
  370. \issue{DEFINE-COMPILER-MACRO:X3J13-NOV89}
  371. or \term{compiler macro}.
  372. \endissue{DEFINE-COMPILER-MACRO:X3J13-NOV89}
  373. (Some exceptions are noted below.)
  374. % added define-condition --sjl 7 Mar 92
  375. \itemitem{4.} Defining it as a \term{type specifier}
  376. (via \macref{defstruct},
  377. \macref{defclass},
  378. \macref{deftype},
  379. \macref{define-condition}).
  380. \itemitem{5.} Defining it as a structure (via \macref{defstruct}).
  381. \itemitem{6.} Defining it as a \term{declaration}
  382. with a \declref{declaration} \term{proclamation}.
  383. \itemitem{7.} Defining it as a \term{symbol macro}.
  384. %%Barmar notes that this can't be done to any symbols.
  385. %% Sandra complained, too.
  386. % \itemitem{n.} Altering its name.
  387. \itemitem{8.} Altering its \term{home package}.
  388. \itemitem{9.} Tracing it (via \macref{trace}).
  389. %What's this "or lexical" biz? -kmp 13-May-91
  390. \itemitem{10.} Declaring or proclaiming it
  391. %% we voted down the lexical declaration proposal. --sjl 7 Mar 92
  392. % \declref{special} or lexical
  393. \declref{special}
  394. (via \misc{declare},
  395. \issue{PROCLAIM-ETC-IN-COMPILE-FILE:NEW-MACRO}
  396. \specref{declaim},
  397. \endissue{PROCLAIM-ETC-IN-COMPILE-FILE:NEW-MACRO}
  398. or \funref{proclaim}).
  399. \itemitem{11.} Declaring or proclaiming its \declref{type} or \declref{ftype}
  400. (via \misc{declare},
  401. \issue{PROCLAIM-ETC-IN-COMPILE-FILE:NEW-MACRO}
  402. \macref{declaim},
  403. \endissue{PROCLAIM-ETC-IN-COMPILE-FILE:NEW-MACRO}
  404. or \funref{proclaim}).
  405. (Some exceptions are noted below.)
  406. \itemitem{12.} Removing it from \thepackage{common-lisp}.
  407. \issue{LISP-SYMBOL-REDEFINITION-AGAIN:MORE-FIXES}
  408. \itemitem{13.} Defining a \term{setf expander} for it
  409. (via \funref{defsetf} or \funref{define-setf-method}).
  410. \itemitem{14.} Defining, undefining, or binding its \term{setf function name}.
  411. \itemitem{15.} Defining it as a \term{method combination} type
  412. (via \funref{define-method-combination}).
  413. \itemitem{16.} Using it as the class-name argument
  414. to \funref{setf} of \funref{find-class}.
  415. \itemitem{17.} Binding it as a \term{catch tag}.
  416. \itemitem{18.} Binding it as a \term{restart} \term{name}.
  417. \itemitem{19.} Defining a \term{method}
  418. for a \term{standardized} \term{generic function}
  419. which is \term{applicable} when all of the \term{arguments}
  420. are \term{direct instances} of \term{standardized} \term{classes}.
  421. \endissue{LISP-SYMBOL-REDEFINITION-AGAIN:MORE-FIXES}
  422. \endlist
  423. \beginsubsubsubsubsection{Some Exceptions to Constraints on the COMMON-LISP Package for Conforming Programs}
  424. If an \term{external symbol} of \thepackage{common-lisp}
  425. is not globally defined as a \term{standardized} \term{dynamic variable}
  426. or \term{constant variable},
  427. it is allowed to lexically \term{bind} it
  428. and to declare the \declref{type} of that \term{binding},
  429. and
  430. it is allowed to locally \term{establish} it as a \term{symbol macro}
  431. (\eg with \specref{symbol-macrolet}).
  432. %KMP: Maybe clarify that binding CL special variables is ok,
  433. % but that their type decls are lexical. Is that right?
  434. %%I implemented the first half of that suggestion. -kmp 15-Feb-92
  435. Unless explicitly specified otherwise,
  436. if an \term{external symbol} of \thepackage{common-lisp}
  437. is globally defined as a \term{standardized} \term{dynamic variable},
  438. it is permitted to \term{bind} or \term{assign} that \term{dynamic variable}
  439. provided that the ``Value Type'' constraints on the \term{dynamic variable}
  440. are maintained, and that the new \term{value} of the \term{variable}
  441. is consistent with the stated purpose of the \term{variable}.
  442. If an \term{external symbol} of \thepackage{common-lisp} is not defined
  443. as a \term{standardized} \term{function}, \term{macro}, or \term{special operator},
  444. it is allowed to lexically \term{bind} it as a \term{function} (\eg with \specref{flet}),
  445. to declare the \declref{ftype} of that \term{binding},
  446. and
  447. %KMP: Barmar wanted some explication here. I think it was sandra who had
  448. % asked for this tracing feature just in case the implementation supported it.
  449. (in \term{implementations} which provide the ability to do so)
  450. to \macref{trace} that \term{binding}.
  451. If an \term{external symbol} of \thepackage{common-lisp} is not defined
  452. as a \term{standardized} \term{function}, \term{macro}, or \term{special operator},
  453. it is allowed to lexically \term{bind} it as a \term{macro} (\eg with \specref{macrolet}).
  454. \endissue{LISP-SYMBOL-REDEFINITION:MAR89-X3J13}
  455. \endissue{LISP-PACKAGE-NAME:COMMON-LISP}
  456. \issue{LISP-SYMBOL-REDEFINITION-AGAIN:MORE-FIXES}
  457. If an \term{external symbol} of \thepackage{common-lisp} is not defined
  458. as a \term{standardized} \term{function}, \term{macro}, or \term{special operator},
  459. it is allowed to lexically \term{bind} its \term{setf function name}
  460. as a \term{function},
  461. and to declare the \declref{ftype} of that \term{binding}.
  462. \endissue{LISP-SYMBOL-REDEFINITION-AGAIN:MORE-FIXES}
  463. \endsubsubsubsubsection%{Some Exceptions to Constraints on the COMMON-LISP Package for Conforming Programs}
  464. \endsubsubsubsection%{Constraints on the COMMON-LISP Package for Conforming Programs}
  465. \endsubsubsection%{The COMMON-LISP Package}
  466. \beginsubsubsection{The COMMON-LISP-USER Package}
  467. \idxpackref{common-lisp-user}\idxpackref{cl-user}
  468. \Thepackage{common-lisp-user} is the \term{current package} when
  469. a \clisp\ system starts up. This \term{package} \term{uses} \thepackage{common-lisp}.
  470. \Thepackage{common-lisp-user} has the \term{nickname} \packref{cl-user}.
  471. \issue{PACKAGE-CLUTTER:REDUCE}
  472. \Thepackage{common-lisp-user} can have additional \term{symbols} \term{interned} within it;
  473. it can \term{use} other \term{implementation-defined} \term{packages}.
  474. \endissue{PACKAGE-CLUTTER:REDUCE}
  475. \endsubsubsection%{The COMMON-LISP-USER Package}
  476. \beginsubsubsection{The KEYWORD Package}
  477. \idxpackref{keyword}
  478. %% 5.1.2 6
  479. %% 11.3.0 5
  480. % % KMP: This isn't a very apt description!
  481. % % %% 11.6.0 4
  482. % \Thepackage{keyword} contains all of the \newterm{keywords}\meaning{1}
  483. % used by built-in or user-defined \term{functions}.
  484. %% Replaced:
  485. \Thepackage{keyword} contains \term{symbols}, called \term{keywords}\meaning{1},
  486. that are typically used as special markers in \term{programs}
  487. and their associated data \term{expressions}\meaning{1}.
  488. \term{Symbol} \term{tokens} that start with a \term{package marker}
  489. are parsed by the \term{Lisp reader} as \term{symbols}
  490. in \thepackage{keyword}; \seesection\SymbolTokens.
  491. This makes it notationally convenient to use \term{keywords}
  492. when communicating between programs in different \term{packages}.
  493. For example, the mechanism for passing \term{keyword parameters} in a \term{call} uses
  494. \term{keywords}\meaning{1} to name the corresponding \term{arguments};
  495. \seesection\OrdinaryLambdaLists.
  496. \term{Symbols} in \thepackage{keyword} are, by definition, \oftype{keyword}.
  497. \beginsubsubsubsection{Interning a Symbol in the KEYWORD Package}
  498. \Thepackage{keyword} is treated differently than other \term{packages}
  499. in that special actions are taken when a \term{symbol} is \term{interned} in it.
  500. In particular, when a \term{symbol} is \term{interned} in \thepackage{keyword},
  501. it is automatically made to be an \term{external symbol}
  502. and is automatically made to be a \term{constant variable} with itself as a \term{value}.
  503. %% Not really needed. This is documented adequately under SYMBOL-VALUE.
  504. % \Thefunction{symbol-value} can be used to
  505. % \term{access} the \term{value} of a \term{keyword}\meaning{1}.)
  506. \endsubsubsubsection%{Interning a Symbol in the KEYWORD Package}
  507. \beginsubsubsubsection{Notes about The KEYWORD Package}
  508. % name conflicts are not an issue because these \term{symbols}
  509. % are used only as labels, not to carry application-specific information.
  510. %% This isn't really true and is arguably confusing.
  511. %% I think the following is what it was getting at. -kmp 15-Feb-92
  512. It is generally best to confine the use of \term{keywords} to situations in which
  513. there are a finitely enumerable set of names to be selected between. For example,
  514. if there were two states of a light switch, they might be called \kwd{on} and \kwd{off}.
  515. In situations where the set of names is not finitely enumerable
  516. (\ie where name conflicts might arise)
  517. it is frequently best to use \term{symbols} in some \term{package}
  518. other than \packref{keyword} so that conflicts will be naturally avoided.
  519. For example, it is generally not wise for a \term{program} to use a \term{keyword}\meaning{1}
  520. as a \term{property indicator}, since if there were ever another \term{program}
  521. that did the same thing, each would clobber the other's data.
  522. \endsubsubsubsection%{Notes about The KEYWORD Package}
  523. \endsubsubsection%{The KEYWORD Package}
  524. \beginsubsubsection{Implementation-Defined Packages}
  525. \issue{PACKAGE-CLUTTER:REDUCE}
  526. Other, \term{implementation-defined} \term{packages} might be present
  527. in the initial \clisp\ environment.
  528. %If it is appropriate, the standard might contain
  529. % as an example that implementations might have a package named
  530. % "SYSTEM".
  531. \endissue{PACKAGE-CLUTTER:REDUCE}
  532. It is recommended, but not required, that the documentation for a
  533. \term{conforming implementation} contain a full list of all \term{package} names
  534. initially present in that \term{implementation} but not specified in this specification.
  535. (See also the \term{function} \funref{list-all-packages}.)
  536. \endsubsubsection%{Implementation-Defined Packages}
  537. \endsubSection%{Standardized Packages}