My various dotfiles

chap-24.texi 34KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  1. @node System Construction, Environment, Reader, Top
  2. @chapter System Construction
  3. @menu
  4. * System Construction Concepts::
  5. * System Construction Dictionary::
  6. @end menu
  7. @node System Construction Concepts, System Construction Dictionary, System Construction, System Construction
  8. @section System Construction Concepts
  9. @c including concept-systems
  10. @menu
  11. * Loading::
  12. * Features::
  13. @end menu
  14. @node Loading, Features, System Construction Concepts, System Construction Concepts
  15. @subsection Loading
  16. To @b{load} a @i{file} is to treat its contents as @i{code}
  17. and @i{execute} that @i{code}.
  18. The @i{file} may contain @i{source code}
  19. @IGindex{source code}
  20. or @i{compiled code}
  21. @IGindex{compiled code}
  22. .
  23. A @i{file} containing @i{source code} is called a @i{source file}
  24. @IGindex{source file}
  25. .
  26. @i{Loading} a @i{source file} is accomplished essentially
  27. by sequentially @i{reading}_2 the @i{forms} in the file,
  28. @i{evaluating} each immediately after it is @i{read}.
  29. A @i{file} containing @i{compiled code} is called a @i{compiled file}
  30. @IGindex{compiled file}
  31. .
  32. @i{Loading} a @i{compiled file} is similar to @i{loading} a @i{source file},
  33. except that the @i{file} does not contain text but rather an
  34. @i{implementation-dependent} representation of pre-digested @i{expressions}
  35. created by the @i{compiler}. Often, a @i{compiled file} can be @i{loaded}
  36. more quickly than a @i{source file}.
  37. See @ref{Compilation}.
  38. The way in which a @i{source file} is distinguished from a @i{compiled file}
  39. is @i{implementation-dependent}.
  40. @node Features, , Loading, System Construction Concepts
  41. @subsection Features
  42. A @i{feature}
  43. @IGindex{feature}
  44. is an aspect or attribute
  45. of @r{Common Lisp},
  46. of the @i{implementation},
  47. or of the @i{environment}.
  48. A @i{feature} is identified by a @i{symbol}.
  49. A @i{feature} is said to be @i{present}
  50. @IGindex{present}
  51. in a @i{Lisp image}
  52. if and only if the @i{symbol} naming it is an @i{element} of the
  53. @i{list} held by the @i{variable} @b{*features*},
  54. which is called the @i{features list}
  55. @IGindex{features list}
  56. .
  57. @menu
  58. * Feature Expressions::
  59. * Examples of Feature Expressions::
  60. @end menu
  61. @node Feature Expressions, Examples of Feature Expressions, Features, Features
  62. @subsubsection Feature Expressions
  63. Boolean combinations of @i{features}, called @i{feature expressions}
  64. @IGindex{feature expression}
  65. ,
  66. are used by the @t{#+} and @t{#-} @i{reader macros} in order to
  67. direct conditional @i{reading} of @i{expressions} by the @i{Lisp reader}.
  68. The rules for interpreting a @i{feature expression} are as follows:
  69. @table @asis
  70. @item @i{feature}
  71. If a @i{symbol} naming a @i{feature} is used as a @i{feature expression},
  72. the @i{feature expression} succeeds if that @i{feature} is @i{present};
  73. otherwise it fails.
  74. @item @t{(not @i{feature-conditional})}
  75. A @b{not} @i{feature expression} succeeds
  76. if its argument @i{feature-conditional} fails;
  77. otherwise, it succeeds.
  78. @item @t{(and @{@i{feature-conditional}@}{*})}
  79. An @b{and} @i{feature expression} succeeds
  80. if all of its argument @i{feature-conditionals} succeed;
  81. otherwise, it fails.
  82. @item @t{(or @{@i{feature-conditional}@}{*})}
  83. An @b{or} @i{feature expression} succeeds
  84. if any of its argument @i{feature-conditionals} succeed;
  85. otherwise, it fails.
  86. @end table
  87. @node Examples of Feature Expressions, , Feature Expressions, Features
  88. @subsubsection Examples of Feature Expressions
  89. For example, suppose that
  90. in @i{implementation} A, the @i{features} @t{spice} and @t{perq} are @i{present},
  91. but the @i{feature} @t{lispm} is not @i{present};
  92. in @i{implementation} B, the feature @t{lispm} is @i{present},
  93. but the @i{features} @t{spice} and @t{perq} are
  94. not @i{present};
  95. and
  96. in @i{implementation} C, none of the features @t{spice}, @i{lispm}, or @t{perq} are
  97. @i{present}.
  98. Figure 24--1 shows some sample @i{expressions}, and how they would be
  99. @i{read}_2 in these @i{implementations}.
  100. @group
  101. @noindent
  102. @w{ @t{(cons #+spice "Spice" #-spice "Lispm" x)} }
  103. @w{ in @i{implementation} A ... @t{(CONS "Spice" X)} }
  104. @w{ in @i{implementation} B ... @t{(CONS "Lispm" X)} }
  105. @w{ in @i{implementation} C ... @t{(CONS "Lispm" X)} }
  106. @w{ @t{(cons #+spice "Spice" #+LispM "Lispm" x)} }
  107. @w{ in @i{implementation} A ... @t{(CONS "Spice" X)} }
  108. @w{ in @i{implementation} B ... @t{(CONS "Lispm" X)} }
  109. @w{ in @i{implementation} C ... @t{(CONS X)} }
  110. @w{ @t{(setq a '(1 2 #+perq 43 #+(not perq) 27))} }
  111. @w{ in @i{implementation} A ... @t{(SETQ A '(1 2 43))} }
  112. @w{ in @i{implementation} B ... @t{(SETQ A '(1 2 27))} }
  113. @w{ in @i{implementation} C ... @t{(SETQ A '(1 2 27))} }
  114. @w{ @t{(let ((a 3) #+(or spice lispm) (b 3)) (foo a))} }
  115. @w{ in @i{implementation} A ... @t{(LET ((A 3) (B 3)) (FOO A))} }
  116. @w{ in @i{implementation} B ... @t{(LET ((A 3) (B 3)) (FOO A))} }
  117. @w{ in @i{implementation} C ... @t{(LET ((A 3)) (FOO A))} }
  118. @w{ @t{(cons #+Lispm "#+Spice" #+Spice "foo" #-(or Lispm Spice) 7 x)} }
  119. @w{ in @i{implementation} A ... @t{(CONS "foo" X)} }
  120. @w{ in @i{implementation} B ... @t{(CONS "#+Spice" X)} }
  121. @w{ in @i{implementation} C ... @t{(CONS 7 X)} }
  122. @noindent
  123. @w{ Figure 24--1: Features examples }
  124. @end group
  125. @c end of including concept-systems
  126. @node System Construction Dictionary, , System Construction Concepts, System Construction
  127. @section System Construction Dictionary
  128. @c including dict-system-construction
  129. @menu
  130. * compile-file::
  131. * compile-file-pathname::
  132. * load::
  133. * with-compilation-unit::
  134. * *features*::
  135. * *compile-file-pathname*::
  136. * *load-pathname*::
  137. * *compile-print*::
  138. * *load-print*::
  139. * *modules*::
  140. * provide::
  141. @end menu
  142. @node compile-file, compile-file-pathname, System Construction Dictionary, System Construction Dictionary
  143. @subsection compile-file [Function]
  144. @code{compile-file} @i{input-file {&key} output-file verbose
  145. print external-format}@*
  146. @result{} @i{output-truename, warnings-p, failure-p}
  147. @subsubheading Arguments and Values::
  148. @i{input-file}---a @i{pathname designator}.
  149. (Default fillers for unspecified components are taken from
  150. @b{*default-pathname-defaults*}.)
  151. @i{output-file}---a @i{pathname designator}.
  152. The default is @i{implementation-defined}.
  153. @i{verbose}---a @i{generalized boolean}.
  154. The default is the @i{value} of @b{*compile-verbose*}.
  155. @i{print}---a @i{generalized boolean}.
  156. The default is the @i{value} of @b{*compile-print*}.
  157. @i{external-format}---an @i{external file format designator}.
  158. The default is @t{:default}.
  159. @i{output-truename}---a @i{pathname} (the @b{truename} of the output @i{file}),
  160. or @b{nil}.
  161. @i{warnings-p}---a @i{generalized boolean}.
  162. @i{failure-p}---a @i{generalized boolean}.
  163. @subsubheading Description::
  164. @b{compile-file} transforms the contents of the file specified
  165. by @i{input-file} into @i{implementation-dependent} binary data
  166. which are placed in the file specified by @i{output-file}.
  167. The @i{file} to which @i{input-file} refers should be a @i{source file}.
  168. @i{output-file} can be used to specify an output @i{pathname};
  169. the actual @i{pathname} of the @i{compiled file}
  170. to which @i{compiled code} will be output
  171. is computed as if by calling @b{compile-file-pathname}.
  172. If @i{input-file} or @i{output-file} is a @i{logical pathname},
  173. it is translated into a @i{physical pathname} as if by calling
  174. @b{translate-logical-pathname}.
  175. If @i{verbose} is @i{true},
  176. @b{compile-file} prints a message in the form of a comment
  177. (@i{i.e.}, with a leading @i{semicolon})
  178. to @i{standard output} indicating what @i{file} is being @i{compiled}
  179. and other useful information.
  180. If @i{verbose} is @i{false},
  181. @b{compile-file} does not print
  182. this information.
  183. If @i{print} is @i{true},
  184. information about @i{top level forms} in the file being
  185. compiled is printed to @i{standard output}.
  186. Exactly what is printed is @i{implementation-dependent},
  187. but nevertheless some information is printed.
  188. If @i{print} is @b{nil}, no information is printed.
  189. The @i{external-format} specifies the @i{external file format}
  190. to be used when opening the @i{file}; see the @i{function} @b{open}.
  191. @b{compile-file} and @b{load} must cooperate in such a way that
  192. the resulting @i{compiled file} can be @i{loaded}
  193. without specifying an @i{external file format} anew; see the @i{function} @b{load}.
  194. @b{compile-file} binds @b{*readtable*} and @b{*package*}
  195. to the values they held before processing the file.
  196. @b{*compile-file-truename*} is bound by @b{compile-file}
  197. to hold the @i{truename} of the @i{pathname} of the file being compiled.
  198. @b{*compile-file-pathname*} is bound by @b{compile-file}
  199. to hold a @i{pathname} denoted by the first argument to @b{compile-file},
  200. merged against the defaults;
  201. that is, @t{(pathname (merge-pathnames @i{input-file}))}.
  202. The compiled @i{functions} contained in the @i{compiled file} become available
  203. for use when the @i{compiled file} is @i{loaded} into Lisp.
  204. Any function definition that is processed by the
  205. compiler, including @t{#'(lambda ...)} forms and local function
  206. definitions made by @b{flet}, @b{labels} and @b{defun} forms,
  207. result in an @i{object} of @i{type} @b{compiled-function}.
  208. The @i{primary value} returned by @b{compile-file}, @i{output-truename},
  209. is the @b{truename} of the output file, or @b{nil} if the file could not be created.
  210. The @i{secondary value}, @i{warnings-p}, is @i{false}
  211. if no @i{conditions} of @i{type} @b{error} or @b{warning}
  212. were detected by the compiler, and @i{true} otherwise.
  213. The @i{tertiary value}, @i{failure-p}, is @i{false}
  214. if no @i{conditions} of @i{type} @b{error} or @b{warning}
  215. (other than @b{style-warning})
  216. were detected by the compiler, and @i{true} otherwise.
  217. For general information about how @i{files} are processed by the @i{file compiler},
  218. see @ref{File Compilation}.
  219. @i{Programs} to be compiled by the @i{file compiler} must only contain
  220. @i{externalizable objects}; for details on such @i{objects},
  221. see @ref{Literal Objects in Compiled Files}.
  222. For information on how to extend the set of @i{externalizable objects},
  223. see the @i{function} @b{make-load-form} and @ref{Additional Constraints on Externalizable Objects}.
  224. @subsubheading Affected By::
  225. @b{*error-output*},
  226. @b{*standard-output*}, @b{*compile-verbose*}, @b{*compile-print*}
  227. The computer's file system.
  228. @subsubheading Exceptional Situations::
  229. For information about errors detected during the compilation process,
  230. see @ref{Exceptional Situations in the Compiler}.
  231. An error of @i{type} @b{file-error} might be signaled if
  232. @t{(wild-pathname-p @i{input-file})\/} returns true.
  233. If either the attempt to open the @i{source file} for input
  234. or the attempt to open the @i{compiled file} for output
  235. fails,
  236. an error of @i{type} @b{file-error} is signaled.
  237. @subsubheading See Also::
  238. @ref{compile}
  239. ,
  240. @b{declare},
  241. @ref{eval-when}
  242. ,
  243. @b{pathname},
  244. @b{logical-pathname},
  245. @ref{File System Concepts},
  246. @ref{Pathnames as Filenames}
  247. @node compile-file-pathname, load, compile-file, System Construction Dictionary
  248. @subsection compile-file-pathname [Function]
  249. @code{compile-file-pathname} @i{input-file {&key} output-file {&allow-other-keys}} @result{} @i{pathname}
  250. @subsubheading Arguments and Values::
  251. @i{input-file}---a @i{pathname designator}.
  252. (Default fillers for unspecified components are taken from
  253. @b{*default-pathname-defaults*}.)
  254. @i{output-file}---a @i{pathname designator}.
  255. The default is @i{implementation-defined}.
  256. @i{pathname}---a @i{pathname}.
  257. @subsubheading Description::
  258. Returns the @i{pathname} that @b{compile-file} would write into,
  259. if given the same arguments.
  260. The defaults for the @i{output-file}
  261. are taken from the @i{pathname}
  262. that results from merging the @i{input-file}
  263. with the @i{value} of @b{*default-pathname-defaults*},
  264. except that the type component
  265. should default to the appropriate
  266. @i{implementation-defined} default type for @i{compiled files}.
  267. If @i{input-file} is a @i{logical pathname} and @i{output-file}
  268. is unsupplied, the result is a @i{logical pathname}.
  269. If @i{input-file} is a @i{logical pathname},
  270. it is translated into a physical pathname as if by calling
  271. @b{translate-logical-pathname}.
  272. If @i{input-file} is a @i{stream},
  273. the @i{stream} can be either open or closed.
  274. @b{compile-file-pathname} returns the same @i{pathname} after a
  275. file is closed as it did when the file was open.
  276. It is an error if @i{input-file} is a @i{stream} that is
  277. created with @b{make-two-way-stream}, @b{make-echo-stream},
  278. @b{make-broadcast-stream}, @b{make-concatenated-stream},
  279. @b{make-string-input-stream}, @b{make-string-output-stream}.
  280. If an implementation supports additional keyword arguments to @b{compile-file},
  281. @b{compile-file-pathname} must accept the same arguments.
  282. @subsubheading Examples::
  283. See @b{logical-pathname-translations}.
  284. @subsubheading Exceptional Situations::
  285. An error of @i{type} @b{file-error} might be signaled if either @i{input-file} or
  286. @i{output-file} is @i{wild}.
  287. @subsubheading See Also::
  288. @ref{compile-file}
  289. ,
  290. @b{pathname},
  291. @b{logical-pathname},
  292. @ref{File System Concepts},
  293. @ref{Pathnames as Filenames}
  294. @node load, with-compilation-unit, compile-file-pathname, System Construction Dictionary
  295. @subsection load [Function]
  296. @code{load} @i{filespec {&key} verbose print
  297. if-does-not-exist external-format}@*
  298. @result{} @i{generalized-boolean}
  299. @subsubheading Arguments and Values::
  300. @i{filespec}---a @i{stream}, or a @i{pathname designator}.
  301. The default is taken from @b{*default-pathname-defaults*}.
  302. @i{verbose}---a @i{generalized boolean}.
  303. The default is the @i{value} of @b{*load-verbose*}.
  304. @i{print}---a @i{generalized boolean}.
  305. The default is the @i{value} of @b{*load-print*}.
  306. @i{if-does-not-exist}---a @i{generalized boolean}.
  307. The default is @i{true}.
  308. @i{external-format}---an @i{external file format designator}.
  309. The default is @t{:default}.
  310. @i{generalized-boolean}---a @i{generalized boolean}.
  311. @subsubheading Description::
  312. @b{load} @i{loads} the @i{file} named by @i{filespec}
  313. into the @r{Lisp} environment.
  314. The manner in which a @i{source file}
  315. is distinguished from a @i{compiled file} is @i{implementation-dependent}.
  316. If the file specification is not complete and both a @i{source file} and a
  317. @i{compiled file} exist which might match,
  318. then which of those files @b{load} selects is @i{implementation-dependent}.
  319. If @i{filespec} is a @i{stream},
  320. @b{load} determines what kind of @i{stream} it is
  321. and loads directly from the @i{stream}.
  322. If @i{filespec} is a @i{logical pathname},
  323. it is translated into a @i{physical pathname}
  324. as if by calling @b{translate-logical-pathname}.
  325. @b{load} sequentially executes each @i{form} it encounters
  326. in the @i{file} named by @i{filespec}.
  327. If the @i{file} is a @i{source file}
  328. and the @i{implementation} chooses to perform @i{implicit compilation},
  329. @b{load} must recognize @i{top level forms}
  330. as described in @ref{Processing of Top Level Forms}
  331. and arrange for each @i{top level form} to be executed
  332. before beginning @i{implicit compilation} of the next.
  333. (Note, however, that processing of @b{eval-when} @i{forms}
  334. by @b{load} is controlled by the @t{:execute} situation.)
  335. If @i{verbose} is @i{true},
  336. @b{load} prints a message in the form of a comment
  337. (@i{i.e.}, with a leading @i{semicolon})
  338. to @i{standard output} indicating what @i{file} is being @i{loaded}
  339. and other useful information.
  340. If @i{verbose} is @i{false},
  341. @b{load} does not print this information.
  342. If @i{print} is @i{true},
  343. @b{load} incrementally prints information to @i{standard output}
  344. showing the progress of the @i{loading} process.
  345. For a @i{source file},
  346. this information might mean printing the @i{values}
  347. @i{yielded} by each @i{form} in the @i{file}
  348. as soon as those @i{values} are returned.
  349. For a @i{compiled file},
  350. what is printed might not reflect precisely the contents of the @i{source file},
  351. but some information is generally printed.
  352. If @i{print} is @i{false},
  353. @b{load} does not print this information.
  354. If the file named by @i{filespec} is successfully loaded,
  355. @b{load} returns @i{true}.
  356. [Reviewer Note by Loosemore: What happens if the file cannot be loaded for some reason other
  357. than that it doesn't exist?]
  358. [Editorial Note by KMP: i.e., can it return NIL? must it?]
  359. If the file does not exist,
  360. the specific action taken depends on @i{if-does-not-exist}:
  361. if it is @b{nil}, @b{load} returns @b{nil};
  362. otherwise, @b{load} signals an error.
  363. The @i{external-format} specifies the @i{external file format}
  364. to be used when opening the @i{file} (see the @i{function} @b{open}),
  365. except that when the @i{file} named by @i{filespec} is a @i{compiled file},
  366. the @i{external-format} is ignored.
  367. @b{compile-file} and @b{load} cooperate
  368. in an @i{implementation-dependent} way to assure
  369. the preservation of the @i{similarity} of @i{characters}
  370. referred to in the @i{source file}
  371. at the time the @i{source file} was processed by the @i{file compiler}
  372. under a given @i{external file format},
  373. regardless of the value of @i{external-format}
  374. at the time the @i{compiled file} is @i{loaded}.
  375. @b{load} binds @b{*readtable*} and @b{*package*}
  376. to the values they held before @i{loading} the file.
  377. @b{*load-truename*} is @i{bound} by @b{load} to hold
  378. the @i{truename} of the @i{pathname} of the file being @i{loaded}.
  379. @b{*load-pathname*} is @i{bound} by @b{load} to hold
  380. a @i{pathname} that represents @i{filespec} merged against the defaults.
  381. That is, @t{(pathname (merge-pathnames @i{filespec}))}.
  382. @subsubheading Examples::
  383. @example
  384. ;Establish a data file...
  385. (with-open-file (str "data.in" :direction :output :if-exists :error)
  386. (print 1 str) (print '(setq a 888) str) t)
  387. @result{} T
  388. (load "data.in") @result{} @i{true}
  389. a @result{} 888
  390. (load (setq p (merge-pathnames "data.in")) :verbose t)
  391. ; Loading contents of file /fred/data.in
  392. ; Finished loading /fred/data.in
  393. @result{} @i{true}
  394. (load p :print t)
  395. ; Loading contents of file /fred/data.in
  396. ; 1
  397. ; 888
  398. ; Finished loading /fred/data.in
  399. @result{} @i{true}
  400. @end example
  401. @example
  402. ;----[Begin file SETUP]----
  403. (in-package "MY-STUFF")
  404. (defmacro compile-truename () `',*compile-file-truename*)
  405. (defvar *my-compile-truename* (compile-truename) "Just for debugging.")
  406. (defvar *my-load-pathname* *load-pathname*)
  407. (defun load-my-system ()
  408. (dolist (module-name '("FOO" "BAR" "BAZ"))
  409. (load (merge-pathnames module-name *my-load-pathname*))))
  410. ;----[End of file SETUP]----
  411. (load "SETUP")
  412. (load-my-system)
  413. @end example
  414. @subsubheading Affected By::
  415. The implementation, and the host computer's file system.
  416. @subsubheading Exceptional Situations::
  417. If @t{:if-does-not-exist} is supplied and is @i{true}, or is not supplied,
  418. @b{load} signals an error of @i{type} @b{file-error} if the file named by
  419. @i{filespec} does not exist,
  420. or if the @i{file system} cannot perform the requested operation.
  421. An error of @i{type} @b{file-error} might be signaled if
  422. @t{(wild-pathname-p @i{filespec})} returns @i{true}.
  423. @subsubheading See Also::
  424. @ref{error}
  425. ,
  426. @ref{merge-pathnames}
  427. ,
  428. @b{*load-verbose*},
  429. @b{*default-pathname-defaults*},
  430. @b{pathname},
  431. @b{logical-pathname},
  432. @ref{File System Concepts},
  433. @ref{Pathnames as Filenames}
  434. @node with-compilation-unit, *features*, load, System Construction Dictionary
  435. @subsection with-compilation-unit [Macro]
  436. @code{with-compilation-unit} @i{@r{(}[[!@i{option}]]@r{)}
  437. @{@i{form}@}{*}} @result{} @i{@{@i{result}@}{*}}
  438. @w{@i{option} ::=@t{:override} override}
  439. @subsubheading Arguments and Values::
  440. @i{override}---a @i{generalized boolean}; evaluated.
  441. The default is @b{nil}.
  442. @i{forms}---an @i{implicit progn}.
  443. @i{results}---the @i{values} returned by the @i{forms}.
  444. @subsubheading Description::
  445. Executes @i{forms} from left to right.
  446. Within the @i{dynamic environment} of @b{with-compilation-unit},
  447. actions deferred by the compiler until the end of compilation will be
  448. deferred until the end of the outermost call to @b{with-compilation-unit}.
  449. The set of @i{options} permitted may be extended by the implementation,
  450. but the only @i{standardized} keyword is @t{:override}.
  451. If nested dynamically only the outer call to
  452. @b{with-compilation-unit} has any effect unless the value
  453. associated with @t{:override} is @i{true}, in which case warnings are
  454. deferred only to the end of the innermost call for which @i{override} is @i{true}.
  455. The function @b{compile-file}
  456. provides the effect of
  457. @example
  458. (with-compilation-unit (:override nil) ...)
  459. @end example
  460. around its @i{code}.
  461. Any @i{implementation-dependent} extensions can only be provided as the
  462. result of an explicit programmer request by use of an
  463. @i{implementation-dependent} keyword. @i{Implementations} are forbidden
  464. from attaching additional meaning to a use of this macro which involves either
  465. no keywords or just the keyword @t{:override}.
  466. @subsubheading Examples::
  467. If an @i{implementation} would normally defer certain kinds of warnings,
  468. such as warnings about undefined functions, to the end of a compilation
  469. unit (such as a @i{file}), the following example shows how to cause those
  470. warnings to be deferred to the end of the compilation of several files.
  471. @example
  472. (defun compile-files (&rest files)
  473. (with-compilation-unit ()
  474. (mapcar #'(lambda (file) (compile-file file)) files)))
  475. (compile-files "A" "B" "C")
  476. @end example
  477. Note however that if the implementation does not normally defer any warnings,
  478. use of @i{with-compilation-unit} might not have any effect.
  479. @subsubheading See Also::
  480. @ref{compile}
  481. ,
  482. @ref{compile-file}
  483. @node *features*, *compile-file-pathname*, with-compilation-unit, System Construction Dictionary
  484. @subsection *features* [Variable]
  485. @subsubheading Value Type::
  486. a @i{proper list}.
  487. @subsubheading Initial Value::
  488. @i{implementation-dependent}.
  489. @subsubheading Description::
  490. The @i{value} of @b{*features*} is called the @i{features list}.
  491. It is a @i{list} of @i{symbols}, called @i{features},
  492. that correspond to some aspect of the @i{implementation} or @i{environment}.
  493. Most @i{features} have @i{implementation-dependent} meanings;
  494. The following meanings have been assigned to feature names:
  495. @table @asis
  496. @item @t{:cltl1}
  497. If present, indicates that the @t{LISP} @i{package} @i{purports to conform}
  498. to the 1984 specification @i{Common Lisp: The Language}.
  499. It is possible, but not required, for a @i{conforming implementation}
  500. to have this feature because this specification specifies that
  501. its @i{symbols} are to be in the @t{COMMON-LISP} @i{package},
  502. not the @t{LISP} package.
  503. @item @t{:cltl2}
  504. If present, indicates that the implementation @i{purports to conform}
  505. to @i{Common Lisp: The Language, Second Edition}.
  506. This feature must not be present in any @i{conforming implementation},
  507. since conformance to that document is not compatible with conformance
  508. to this specification.
  509. The name, however, is reserved by this specification in order to help
  510. programs distinguish implementations which conform to that document
  511. from implementations which conform to this specification.
  512. @item @t{:ieee-floating-point}
  513. If present, indicates that the implementation @i{purports to conform}
  514. to the requirements of @i{IEEE Standard for Binary Floating-Point Arithmetic}.
  515. @item @t{:x3j13}
  516. If present, indicates that the implementation conforms to some
  517. particular working draft of this specification,
  518. or to some subset of features that approximates a belief about
  519. what this specification might turn out to contain.
  520. A @i{conforming implementation} might or might not contain
  521. such a feature.
  522. (This feature is intended primarily as a stopgap in order to
  523. provide implementors something to use prior to the availability
  524. of a draft standard, in order to discourage them from introducing
  525. the @t{:draft-ansi-cl} and @t{:ansi-cl} @i{features} prematurely.)
  526. @item @t{:draft-ansi-cl}
  527. If present, indicates that the @i{implementation}
  528. @i{purports to conform} to the first full draft of this specification,
  529. which went to public review in 1992.
  530. A @i{conforming implementation}
  531. which has the @t{:draft-ansi-cl-2} or @t{:ansi-cl} @i{feature}
  532. is not permitted to retain the @t{:draft-ansi-cl} @i{feature}
  533. since incompatible changes were made subsequent to the first draft.
  534. @item @t{:draft-ansi-cl-2}
  535. If present, indicates that a second full draft of this specification
  536. has gone to public review, and that the @i{implementation}
  537. @i{purports to conform} to that specification.
  538. (If additional public review drafts are produced, this keyword
  539. will continue to refer to the second draft, and additional keywords
  540. will be added to identify conformance with such later drafts.
  541. As such, the meaning of this keyword can be relied upon not to
  542. change over time.)
  543. A @i{conforming implementation} which has the @t{:ansi-cl}
  544. @i{feature} is only permitted to retain the @t{:draft-ansi-cl}
  545. @i{feature} if the finally approved standard is not incompatible
  546. with the draft standard.
  547. @item @t{:ansi-cl}
  548. If present, indicates that this specification has been adopted by ANSI
  549. as an official standard, and that the @i{implementation}
  550. @i{purports to conform}.
  551. @item @t{:common-lisp}
  552. This feature must appear in @b{*features*} for any implementation that
  553. has one or more of the features @t{:x3j13}, @t{:draft-ansi-cl},
  554. or @t{:ansi-cl}. It is intended that it should also appear in
  555. implementations which have the features @t{:cltl1} or @t{:cltl2},
  556. but this specification cannot force such behavior. The intent is
  557. that this feature should identify the language family named ``Common Lisp,''
  558. rather than some specific dialect within that family.
  559. @end table
  560. @subsubheading See Also::
  561. @ref{Use of Read-Time Conditionals},
  562. @ref{Standard Macro Characters}
  563. @subsubheading Notes::
  564. The @i{value} of @b{*features*} is used by the @t{#+} and @t{#-} reader syntax.
  565. @i{Symbols} in the @i{features list} may be in any @i{package},
  566. but in practice they are generally in the @t{KEYWORD} @i{package}.
  567. This is because @t{KEYWORD} is the @i{package} used by default
  568. when @i{reading}_2 @i{feature expressions}
  569. in the @t{#+} and @t{#-} @i{reader macros}.
  570. @i{Code} that needs to name a @i{feature}_2 in a
  571. @i{package} P (other than @t{KEYWORD}) can do so
  572. by making explicit use of a @i{package prefix} for P,
  573. but note that such @i{code} must also assure that the @i{package} P
  574. exists in order for the @i{feature expression} to be @i{read}_2---even
  575. in cases where the @i{feature expression} is expected to fail.
  576. It is generally considered wise for an @i{implementation} to include
  577. one or more @i{features} identifying the specific @i{implementation},
  578. so that conditional expressions can be written which distinguish
  579. idiosyncrasies of one @i{implementation} from those of another.
  580. Since features are normally @i{symbols} in the @t{KEYWORD} @i{package}
  581. where name collisions might easily result, and since no uniquely defined mechanism
  582. is designated for deciding who has the right to use which @i{symbol} for
  583. what reason, a conservative strategy is to prefer names derived from
  584. one's own company or product name, since those names are often trademarked
  585. and are hence less likely to be used unwittingly by another @i{implementation}.
  586. @node *compile-file-pathname*, *load-pathname*, *features*, System Construction Dictionary
  587. @subsection *compile-file-pathname*, *compile-file-truename* [Variable]
  588. @subsubheading Value Type::
  589. The @i{value} of @b{*compile-file-pathname*} must always be a @i{pathname} or @b{nil}.
  590. The @i{value} of @b{*compile-file-truename*} must always be a @i{physical pathname} or @b{nil}.
  591. @subsubheading Initial Value::
  592. @b{nil}.
  593. @subsubheading Description::
  594. During a call to @b{compile-file},
  595. @b{*compile-file-pathname*} is @i{bound} to
  596. the @i{pathname} denoted by the first argument to @b{compile-file},
  597. merged against the defaults;
  598. that is, it is @i{bound} to @t{(pathname (merge-pathnames @i{input-file}))}.
  599. During the same time interval,
  600. @b{*compile-file-truename*} is @i{bound} to
  601. the @i{truename} of the @i{file} being @i{compiled}.
  602. At other times, the @i{value} of these @i{variables} is @b{nil}.
  603. If a @i{break loop} is entered while @b{compile-file} is ongoing,
  604. it is @i{implementation-dependent} whether these @i{variables} retain
  605. the @i{values} they had just prior to entering the @i{break loop}
  606. or whether they are @i{bound} to @b{nil}.
  607. The consequences are unspecified if
  608. an attempt is made to @i{assign} or @i{bind} either of these @i{variables}.
  609. @subsubheading Affected By::
  610. The @i{file system}.
  611. @subsubheading See Also::
  612. @ref{compile-file}
  613. @node *load-pathname*, *compile-print*, *compile-file-pathname*, System Construction Dictionary
  614. @subsection *load-pathname*, *load-truename* [Variable]
  615. @subsubheading Value Type::
  616. The @i{value} of @b{*load-pathname*} must always be a @i{pathname} or @b{nil}.
  617. The @i{value} of @b{*load-truename*} must always be a @i{physical pathname} or @b{nil}.
  618. @subsubheading Initial Value::
  619. @b{nil}.
  620. @subsubheading Description::
  621. During a call to @b{load},
  622. @b{*load-pathname*} is @i{bound} to
  623. the @i{pathname} denoted by the the first argument to @b{load},
  624. merged against the defaults;
  625. that is, it is @i{bound} to @t{(pathname (merge-pathnames @i{filespec}))}.
  626. During the same time interval,
  627. @b{*load-truename*} is @i{bound} to
  628. the @i{truename} of the @i{file} being loaded.
  629. At other times, the @i{value} of these @i{variables} is @b{nil}.
  630. If a @i{break loop} is entered while @b{load} is ongoing,
  631. it is @i{implementation-dependent} whether these @i{variables} retain
  632. the @i{values} they had just prior to entering the @i{break loop}
  633. or whether they are @i{bound} to @b{nil}.
  634. The consequences are unspecified if
  635. an attempt is made to @i{assign} or @i{bind} either of these @i{variables}.
  636. @subsubheading Affected By::
  637. The @i{file system}.
  638. @subsubheading See Also::
  639. @ref{load}
  640. @node *compile-print*, *load-print*, *load-pathname*, System Construction Dictionary
  641. @subsection *compile-print*, *compile-verbose* [Variable]
  642. @subsubheading Value Type::
  643. a @i{generalized boolean}.
  644. @subsubheading Initial Value::
  645. @i{implementation-dependent}.
  646. @subsubheading Description::
  647. The @i{value} of @b{*compile-print*} is the default value of the @t{:print} @i{argument}
  648. to @b{compile-file}.
  649. The @i{value} of @b{*compile-verbose*} is the default value of the @t{:verbose} @i{argument}
  650. to @b{compile-file}.
  651. @subsubheading See Also::
  652. @ref{compile-file}
  653. @node *load-print*, *modules*, *compile-print*, System Construction Dictionary
  654. @subsection *load-print*, *load-verbose* [Variable]
  655. @subsubheading Value Type::
  656. a @i{generalized boolean}.
  657. @subsubheading Initial Value::
  658. The initial @i{value} of @b{*load-print*} is @i{false}.
  659. The initial @i{value} of @b{*load-verbose*} is @i{implementation-dependent}.
  660. @subsubheading Description::
  661. The @i{value} of @b{*load-print*} is the default value of the @t{:print} @i{argument} to @b{load}.
  662. The @i{value} of @b{*load-verbose*} is the default value of the @t{:verbose} @i{argument} to @b{load}.
  663. @subsubheading See Also::
  664. @ref{load}
  665. @node *modules*, provide, *load-print*, System Construction Dictionary
  666. @subsection *modules* [Variable]
  667. @subsubheading Value Type::
  668. a @i{list} of @i{strings}.
  669. @subsubheading Initial Value::
  670. @i{implementation-dependent}.
  671. @subsubheading Description::
  672. The @i{value} of @b{*modules*} is a list of names of the modules
  673. that have been loaded into the current @i{Lisp image}.
  674. @subsubheading Affected By::
  675. @b{provide}
  676. @subsubheading See Also::
  677. @ref{provide; require}
  678. ,
  679. @b{require}
  680. @subsubheading Notes::
  681. The variable @b{*modules*} is deprecated.
  682. @node provide, , *modules*, System Construction Dictionary
  683. @subsection provide, require [Function]
  684. @code{provide} @i{module-name} @result{} @i{@i{implementation-dependent}}
  685. @code{require} @i{module-name {&optional} pathname-list} @result{} @i{@i{implementation-dependent}}
  686. @subsubheading Arguments and Values::
  687. @i{module-name}---a @i{string designator}.
  688. @i{pathname-list}---@b{nil}, or
  689. a @i{designator}
  690. for a @i{non-empty} @i{list} of @i{pathname designators}.
  691. The default is @b{nil}.
  692. @subsubheading Description::
  693. @b{provide} adds the @i{module-name} to the @i{list} held by
  694. @b{*modules*}, if such a name is not already present.
  695. @b{require} tests for the presence of the @i{module-name} in the
  696. @i{list} held by @b{*modules*}.
  697. If it is present, @b{require} immediately returns.
  698. Otherwise, an attempt is made to load an appropriate set of @i{files} as follows:
  699. The @i{pathname-list} argument, if @i{non-nil},
  700. specifies a list of @i{pathnames} to be loaded in order, from left to right.
  701. If the @i{pathname-list} is @b{nil},
  702. an @i{implementation-dependent} mechanism will be invoked in an attempt
  703. to load the module named @i{module-name};
  704. if no such module can be loaded, an error of @i{type} @b{error} is signaled.
  705. Both functions use @b{string=} to test for the presence of a @i{module-name}.
  706. @subsubheading Examples::
  707. @example
  708. ;;; This illustrates a nonportable use of REQUIRE, because it
  709. ;;; depends on the implementation-dependent file-loading mechanism.
  710. (require "CALCULUS")
  711. ;;; This use of REQUIRE is nonportable because of the literal
  712. ;;; physical pathname.
  713. (require "CALCULUS" "/usr/lib/lisp/calculus")
  714. ;;; One form of portable usage involves supplying a logical pathname,
  715. ;;; with appropriate translations defined elsewhere.
  716. (require "CALCULUS" "lib:calculus")
  717. ;;; Another form of portable usage involves using a variable or
  718. ;;; table lookup function to determine the pathname, which again
  719. ;;; must be initialized elsewhere.
  720. (require "CALCULUS" *calculus-module-pathname*)
  721. @end example
  722. @subsubheading Side Effects::
  723. @b{provide} modifies @b{*modules*}.
  724. @subsubheading Affected By::
  725. The specific action taken by @b{require} is affected by calls to @b{provide}
  726. (or, in general, any changes to the @i{value} of @b{*modules*}).
  727. @subsubheading Exceptional Situations::
  728. Should signal an error of @i{type} @b{type-error}
  729. if @i{module-name} is not a @i{string designator}.
  730. If @b{require} fails to perform the requested operation
  731. due to a problem while interacting with the @i{file system},
  732. an error of @i{type} @b{file-error} is signaled.
  733. An error of @i{type} @b{file-error} might be signaled if any @i{pathname}
  734. in @i{pathname-list} is a @i{designator} for a @i{wild} @i{pathname}.
  735. @subsubheading See Also::
  736. @b{*modules*},
  737. @ref{Pathnames as Filenames}
  738. @subsubheading Notes::
  739. The functions @b{provide} and @b{require} are deprecated.
  740. If a module consists of a single @i{package},
  741. it is customary for the package and module names to be the same.
  742. @c end of including dict-system-construction
  743. @c %**end of chapter