concept-macro-chars.tex 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419
  1. % -*- Mode: TeX -*-
  2. %% Standard Macro Characters
  3. %% 22.1.3 1
  4. If the reader encounters a \term{macro character},
  5. then its associated \term{reader macro function}
  6. is invoked and may produce an \term{object} to be returned.
  7. This \term{function} may read the \term{characters}
  8. following the \term{macro character} in the \term{stream}
  9. in any syntax and return the \term{object} represented by that syntax.
  10. %% 22.1.3 2
  11. Any \term{character} can be made to be a \term{macro character}.
  12. The \term{macro characters} defined initially in a \term{conforming implementation}
  13. include
  14. the following:
  15. \beginsubsection{Left-Parenthesis}
  16. \DefineSection{LeftParen}\idxcode{(}\idxtext{Left-Parenthesis (reader macro)}\idxref{list}
  17. %% 22.1.3 3
  18. %% 2.4.0 3
  19. The \term{left-parenthesis} initiates reading of a \term{list}.
  20. \funref{read} is called recursively to read successive \term{objects}
  21. until a right parenthesis is found in the input \term{stream}.
  22. A \term{list} of the \term{objects} read is returned. Thus
  23. \code
  24. (a b c)
  25. \endcode
  26. is read as a \term{list} of three \term{objects}
  27. (the \term{symbols} \f{a}, \f{b}, and \f{c}).
  28. The right parenthesis need not immediately follow the printed representation of
  29. the last \term{object}; \term{whitespace}\meaning{2}
  30. characters and comments may precede it.
  31. %\code
  32. % (defun traffic-light (color)
  33. % (case color
  34. % (green)
  35. % (red (stop))
  36. % (amber (accelerate)) ;Insert more colors after this line.
  37. % ))
  38. %\endcode
  39. %% 22.1.3 4
  40. If no \term{objects} precede the right parenthesis,
  41. it reads as a \term{list} of zero \term{objects}
  42. (the \term{empty list}).
  43. %% 22.1.3 5
  44. If a \term{token} that is just a dot\idxterm{dot}\idxcode{.}
  45. not immediately preceded by an escape character
  46. is read after some \term{object}
  47. then exactly one more \term{object} must follow the dot,
  48. possibly preceded or followed by \term{whitespace}\meaning{2} or a comment,
  49. followed by the right parenthesis:
  50. \code
  51. (a b c . d)
  52. \endcode
  53. This means that the \term{cdr} of the last \term{cons} in the
  54. \term{list} is not \nil,
  55. but rather the \term{object} whose representation followed the dot.
  56. The above example might have been the result of evaluating
  57. \code
  58. (cons 'a (cons 'b (cons 'c 'd)))
  59. \endcode
  60. Similarly,
  61. \code
  62. (cons 'this-one 'that-one) \EV (this-one . that-one)
  63. \endcode
  64. It is permissible for the \term{object}
  65. following the dot to be a \term{list}:
  66. \code
  67. (a b c d . (e f . (g))) \EQ (a b c d e f g)
  68. \endcode
  69. For information on how the \term{Lisp printer} prints \term{lists} and \term{conses},
  70. \seesection\PrintingListsAndConses.
  71. \endsubsection%{Left-Parenthesis}
  72. \beginsubsection{Right-Parenthesis}
  73. \idxcode{)}\idxtext{Right-Parenthesis (reader macro)}
  74. %% 22.1.3 6
  75. The \term{right-parenthesis} is invalid
  76. except when used in conjunction with the left parenthesis character.
  77. For more information, \seesection\ReaderAlgorithm.
  78. \endsubsection%{Right-Parenthesis}
  79. \beginsubsection{Single-Quote}
  80. \DefineSection{QuoteMacro}
  81. \idxcode{'}\idxtext{Single-Quote (reader macro)}\idxtext{quotation (of forms)}\idxref{quote}
  82. \b{Syntax:} \f{'\metaparam{exp}}
  83. %% 22.1.3 7
  84. A \term{single-quote} introduces an \term{expression} to be ``quoted.''
  85. \term{Single-quote} followed by an \term{expression} \param{exp}
  86. is treated by the \term{Lisp reader} as an abbreviation for
  87. and is parsed identically to the \term{expression} \f{(quote \param{exp})}.
  88. \Seespec{quote}.
  89. \beginsubsubsection{Examples of Single-Quote}
  90. \code
  91. 'foo \EV FOO
  92. ''foo \EV (QUOTE FOO)
  93. (car ''foo) \EV QUOTE
  94. \endcode
  95. \endsubsubsection%{Examples of Single-Quote}
  96. \endsubsection%{Single-Quote}
  97. \beginsubsection{Semicolon}
  98. \idxcode{;}\idxtext{Semicolon (reader macro)}\idxtext{comment}
  99. \b{Syntax:} \f{;\metaparam{text}}
  100. %% 22.1.3 8
  101. A \term{semicolon} introduces \term{characters} that are to be ignored,
  102. such as comments. The \term{semicolon} and all \term{characters} up to
  103. and including the next \term{newline} or end of file are ignored.
  104. \beginsubsubsection{Examples of Semicolon}
  105. \code
  106. (+ 3 ; three
  107. 4)
  108. \EV 7
  109. \endcode
  110. \endsubsubsection%{Examples of Semicolon}
  111. \beginsubsubsection{Notes about Style for Semicolon}
  112. Some text editors make assumptions about desired indentation based on
  113. the number of \term{semicolons} that begin a comment. The following style
  114. conventions are common, although not by any means universal.
  115. \beginsubsubsubsection{Use of Single Semicolon}
  116. %% 22.1.3 9
  117. Comments that begin with a single \term{semicolon} are all aligned to
  118. the same column at the right (sometimes called the ``comment column'').
  119. The text of such a comment generally applies only to the line on which it appears.
  120. Occasionally two or three contain a single sentence together;
  121. this is sometimes indicated by indenting all but the first with an additional
  122. space (after the \term{semicolon}).
  123. \endsubsubsubsection%{Use of Single Semicolon}
  124. \beginsubsubsubsection{Use of Double Semicolon}
  125. %% 22.1.3 10
  126. Comments that begin with a double \term{semicolon} are all aligned to
  127. the same level of indentation as a \term{form} would be at that same
  128. position in the \term{code}.
  129. %% I think this is a matter of personal taste,
  130. %% independent of the semicolon convention. -kmp 25-Jan-92
  131. % A space generally follows the two semicolons.
  132. The text of such a comment usually describes
  133. the state of the \term{program} at the point where the comment occurs,
  134. the \term{code} which follows the comment,
  135. or both.
  136. \endsubsubsubsection%{Use of Double Semicolon}
  137. \beginsubsubsubsection{Use of Triple Semicolon}
  138. %% 22.1.3 11
  139. Comments that begin with a triple \term{semicolon} are all aligned to
  140. the left margin. Usually they are used prior to a definition or set
  141. of definitions, rather than within a definition.
  142. \endsubsubsubsection%{Use of Triple Semicolon}
  143. %% 22.1.3 12
  144. \beginsubsubsubsection{Use of Quadruple Semicolon}
  145. Comments that begin with a quadruple \term{semicolon} are all aligned to
  146. the left margin, and generally contain only a short piece of text that
  147. serve as a title for the code which follows, and might be used in the
  148. header or footer of a program that prepares code for presentation as
  149. a hardcopy document.
  150. \endsubsubsubsection%{Use of Quadruple Semicolon}
  151. \beginsubsubsubsection{Examples of Style for Semicolon}
  152. \code
  153. ;;;; Math Utilities
  154. ;;; FIB computes the the Fibonacci function in the traditional
  155. ;;; recursive way.
  156. (defun fib (n)
  157. (check-type n integer)
  158. ;; At this point we're sure we have an integer argument.
  159. ;; Now we can get down to some serious computation.
  160. (cond ((< n 0)
  161. ;; Hey, this is just supposed to be a simple example.
  162. ;; Did you really expect me to handle the general case?
  163. (error "FIB got ~D as an argument." n))
  164. ((< n 2) n) ;fib[0]=0 and fib[1]=1
  165. ;; The cheap cases didn't work.
  166. ;; Nothing more to do but recurse.
  167. (t (+ (fib (- n 1)) ;The traditional formula
  168. (fib (- n 2)))))) ; is fib[n-1]+fib[n-2].
  169. \endcode
  170. \endsubsubsubsection%{Examples of Style for Semicolon}
  171. \endsubsubsection%{Notes about Style for Semicolon}
  172. \endsubsection%{Semicolon}
  173. \beginsubsection{Double-Quote}
  174. \DefineSection{Doublequote}
  175. \idxtext{Double-Quote (reader macro)}\idxtext{quotation (of strings)}\idxref{string}
  176. \b{Syntax:} \f{"\metaparam{text}"}
  177. %% 22.1.3 14
  178. %% 2.5.2 1
  179. The \term{double-quote} is used to begin and end a \term{string}.
  180. When a \term{double-quote} is encountered,
  181. \term{characters} are read from the \term{input} \term{stream}
  182. and accumulated until another \term{double-quote} is encountered.
  183. If a \term{single escape} \term{character} is seen,
  184. the \term{single escape} \term{character} is discarded,
  185. the next \term{character} is accumulated, and accumulation continues.
  186. %% 2.5.2 3
  187. The accumulated \term{characters}
  188. up to but not including the matching \term{double-quote}
  189. are made into a \term{simple string} and returned.
  190. \issue{CHARACTER-PROPOSAL:2-1-1}
  191. It is \term{implementation-dependent}
  192. which \term{attributes} of the accumulated characters are removed in this process.
  193. \endissue{CHARACTER-PROPOSAL:2-1-1}
  194. Examples of the use of the \term{double-quote} character are in \thenextfigure.
  195. \showtwo{Examples of the use of double-quote}{
  196. \f{"Foo"} & ;A string with three characters in it \cr
  197. \f{""} & ;An empty string \cr
  198. \f{"\\"APL\\\\360?\\" he cried."} & ;A string with twenty characters \cr
  199. \f{"|x| = |-x|"} & ;A ten-character string \cr
  200. }
  201. Note that to place a single escape character or a \term{double-quote} into a string,
  202. such a character must be preceded by a single escape character.
  203. Note, too, that a multiple escape character need not be quoted by a
  204. single escape character within a string.
  205. %% 2.5.2 2
  206. %With the exception of unquoted escape characters,
  207. %the characters contained by the double-quotes, taken from left to right,
  208. %occupy locations within the string with increasing indices.
  209. %The leftmost character is string element number 0, the next one
  210. %is element number 1, and so on.
  211. For information on how the \term{Lisp printer} prints \term{strings},
  212. \seesection\PrintingStrings.
  213. \endsubsection%{Double-Quote}
  214. \beginsubsection{Backquote}
  215. \DefineSection{Backquote}
  216. \idxcode{`}\idxtext{Backquote (reader macro)}\idxtext{quotation (of forms)}
  217. \idxref{quote}\idxref{list}\idxref{cons}
  218. %% 22.1.3 15
  219. The \term{backquote} introduces a template of a data structure to be built.
  220. For example, writing
  221. \code
  222. `(cond ((numberp ,x) ,@y) (t (print ,x) ,@y))
  223. \endcode
  224. is roughly equivalent to writing
  225. \code
  226. (list 'cond
  227. (cons (list 'numberp x) y)
  228. (list* 't (list 'print x) y))
  229. \endcode
  230. Where a comma
  231. occurs in the template,
  232. the \term{expression}
  233. following the comma is to be evaluated to produce an \term{object} to
  234. be inserted at that point. Assume \f{b} has the value 3, for example, then
  235. evaluating the \term{form} denoted by \f{`(a b ,b ,(+ b 1) b)} produces
  236. the result \f{(a b 3 4 b)}.
  237. %% 22.1.3 16
  238. If a comma is immediately followed by an \term{at-sign},
  239. then the \term{form} following the \term{at-sign}
  240. is evaluated to produce a \term{list} of \term{objects}.
  241. These \term{objects} are then ``spliced'' into place in the template. For
  242. example, if \f{x} has the value \f{(a b c)}, then
  243. \code
  244. `(x ,x ,@x foo ,(cadr x) bar ,(cdr x) baz ,@(cdr x))
  245. \EV (x (a b c) a b c foo b bar (b c) baz b c)
  246. \endcode
  247. %% 22.1.3 17
  248. The backquote syntax can be summarized formally as follows.
  249. \beginlist
  250. \itemitem{\bull}
  251. \f{`\param{basic}} is the same as \f{'\param{basic}},
  252. that is, \f{(quote \param{basic})}, for any \term{expression}
  253. \param{basic} that is not a \term{list} or a general \term{vector}.
  254. %% 22.1.3 18
  255. \itemitem{\bull}
  256. \f{`,\param{form}} is the same as \param{form}, for any \param{form}, provided
  257. that the representation of \param{form} does not begin with \term{at-sign}
  258. or \term{dot}. (A similar caveat holds for all occurrences of a form after a \term{comma}.)
  259. %% 22.1.3 19
  260. \itemitem{\bull}
  261. \f{`,@\param{form}} has undefined consequences.
  262. %% 22.1.3 20
  263. \itemitem{\bull}
  264. \f{`(x1 x2 x3 ... xn . atom)}
  265. may be interpreted to mean
  266. \code
  267. (append \lbracket\ x1\rbracket \lbracket\ x2\rbracket \lbracket\ x3\rbracket ... \lbracket\ xn\rbracket (quote atom))
  268. \endcode
  269. where the brackets are used to indicate
  270. a transformation of an \param{xj} as follows:
  271. %% 22.1.3 21
  272. \beginlist
  273. \itemitem{--}
  274. \f{[\param{form}]} is interpreted as \f{(list `\param{form})},
  275. which contains a backquoted form that must then be further interpreted.
  276. %% 22.1.3 22
  277. \itemitem{--}
  278. \f{[,\param{form}]} is interpreted as \f{(list \param{form})}.
  279. %% 22.1.3 23
  280. \itemitem{--}
  281. \f{[,@\param{form}]} is interpreted as \param{form}.
  282. \endlist
  283. %% 22.1.3 24
  284. \itemitem{\bull}
  285. \f{`(x1 x2 x3 ... xn)} may be interpreted to mean
  286. the same as the backquoted form
  287. \f{`(x1 x2 x3 ... xn . \nil)},
  288. thereby reducing it to the previous case.
  289. %% 22.1.3 25
  290. \itemitem{\bull}
  291. \f{`(x1 x2 x3 ... xn . ,form)} may be interpreted to mean
  292. \code
  293. (append \lbracket\ x1\rbracket \lbracket\ x2\rbracket \lbracket\ x3\rbracket ... \lbracket\ xn\rbracket form)
  294. \endcode
  295. where the brackets indicate a transformation of an {\tt xj} as described above.
  296. %% 22.1.3 26
  297. \itemitem{\bull}
  298. \f{`(x1 x2 x3 ... xn . ,@form)} has undefined consequences.
  299. %% 22.1.3 27
  300. \itemitem{\bull}
  301. \f{`\#(x1 x2 x3 ... xn)} may be interpreted to mean
  302. \f{(apply \#'vector `(x1 x2 x3 ... xn))}.
  303. \endlist
  304. %% 22.1.3 28
  305. Anywhere ``\f{,@}'' may be used, the syntax ``\f{,.}'' may be used instead
  306. to indicate that it is permissible to operate \term{destructively} on
  307. the \term{list structure} produced by the form following the ``\f{,.}''
  308. (in effect, to use \funref{nconc} instead of \funref{append}).
  309. %% 22.1.3 29
  310. If the backquote syntax is nested, the innermost backquoted form
  311. should be expanded first. This means that if several commas occur
  312. in a row, the leftmost one belongs to the innermost \term{backquote}.
  313. %% 22.1.3 30
  314. % An implementation is free to interpret
  315. % a backquoted form as any form that, when evaluated, will produce a result
  316. % that is \funref{equal} to the result implied by the above definition.
  317. % % Barmar:
  318. % % Except for the non-destructive nature of ,@.
  319. % % It must also cons a new top-level list if comma is used. e.g.,
  320. % % (defun foo (x) `'(,x))
  321. % % (eq (foo 1) (foo 2)) => \term{false}
  322. % % i.e., it can't cache a structure and then replac it each time.
  323. % %
  324. %% Rewritten for Barmar. -kmp 11-Feb-92
  325. An \term{implementation} is free to interpret a backquoted \term{form} $F\sub 1$
  326. as any \term{form} $F\sub 2$ that, when evaluated, will produce a result that is
  327. the \term{same} under \funref{equal} as the result implied by the above definition,
  328. provided that the side-effect behavior of the substitute \term{form} $F\sub 2$
  329. is also consistent with the description given above.
  330. %End of rewrite.
  331. The constructed
  332. copy of the template might or might not share \term{list} structure with the
  333. template itself. As an example, the above definition implies that
  334. \code
  335. `((,a b) ,c ,@d)
  336. \endcode
  337. will be interpreted as if it were
  338. \code
  339. (append (list (append (list a) (list 'b) '\nil)) (list c) d '\nil)
  340. \endcode
  341. but it could also be legitimately interpreted to mean any of the following:
  342. \code
  343. (append (list (append (list a) (list 'b))) (list c) d)
  344. (append (list (append (list a) '(b))) (list c) d)
  345. (list* (cons a '(b)) c d)
  346. (list* (cons a (list 'b)) c d)
  347. (append (list (cons a '(b))) (list c) d)
  348. (list* (cons a '(b)) c (copy-list d))
  349. \endcode
  350. \beginsubsubsection{Notes about Backquote}
  351. Since the exact manner in which the \term{Lisp reader} will parse
  352. an \term{expression} involving the \term{backquote} \term{reader macro}
  353. is not specified, an \term{implementation} is free to choose any
  354. representation that preserves the semantics described.
  355. Often an \term{implementation} will choose a representation that facilitates
  356. pretty printing of the expression, so that \f{(pprint `(a ,b))} will display
  357. \f{`(a ,b)} and not, for example, \f{(list 'a b)}. However, this is not a
  358. requirement.
  359. Implementors who have no particular reason to make one choice or another
  360. might wish to refer to {\IEEEScheme}, which identifies a popular choice of
  361. representation for such expressions that might provide useful to be useful
  362. compatibility for some user communities. There is no requirement, however,
  363. that any \term{conforming implementation} use this particular representation.
  364. This information is provided merely for cross-reference purposes.
  365. \endsubsubsection%{Notes about Backquote}
  366. \endsubsection%{Backquote}
  367. \beginsubsection{Comma}
  368. \idxcode{,}\idxtext{Comma (reader macro)}\idxtext{quotation (of forms)}
  369. \idxref{quote}\idxref{list}\idxref{cons}
  370. %% 22.1.3 31
  371. The \term{comma} is part of the backquote syntax; \seesection\Backquote.
  372. \term{Comma} is invalid if used other than inside the body of a
  373. backquote \term{expression} as described above.
  374. \endsubsection%{Comma}
  375. \beginsubsection{Sharpsign}
  376. \idxcode{\#}\idxtext{Sharpsign (reader macro)}
  377. %% 22.1.3 32
  378. %% 22.1.3 33
  379. \term{Sharpsign} is a \term{non-terminating} \term{dispatching macro character}.
  380. It reads an optional
  381. %was "digit \term{string}". ugh. -kmp 10-Apr-91
  382. sequence of digits and then one more character,
  383. and uses that character to select a \term{function} to run as a
  384. \term{reader macro function}.
  385. %% 22.1.4 1
  386. The \term{standard syntax} includes constructs introduced by the \f{\#} character.
  387. The syntax of these constructs is as follows:
  388. a character that identifies the type of construct is
  389. followed by arguments in some form.
  390. If the character is a letter, its \term{case} is not important;
  391. \f{\#O} and \f{\#o} are considered to be equivalent, for example.
  392. %% 22.1.4 2
  393. Certain \f{\#} constructs allow an unsigned decimal number to appear
  394. between the \f{\#} and the character.
  395. %% 22.1.4 4
  396. The \term{reader macros} associated with the \term{dispatching macro character} \f{\#}
  397. are described later in this section and summarized in \thenextfigure.
  398. %% 22.1.4 3
  399. % \boxfig
  400. % {
  401. % \def\u{undefined}
  402. % \def\s{signals error}
  403. % \def\ia{infix argument}
  404. % \tabskip 1pc
  405. % \halign to \hsize {#\hfil\tabskip 1pc&#\hfil\tabskip 0pt plus 1fil
  406. % &#\hfil\tabskip 1pc&#\hfil\cr
  407. % \noalign{\vskip -9pt}
  408. % \omit\bf character&\omit\bf purpose&\omit\bf character& \omit\bf purpose\cr
  409. % \omit\bf combination&\omit&\omit\bf combination\cr
  410. % \noalign{\vskip 2pt\hrule\vskip 2pt}
  411. % Backspace&\s&\f{\{}&\u*\cr
  412. % Tab&\s&\f{\}}&\u*\cr
  413. % Newline&\s&+&read-time conditional\cr
  414. % Linefeed&\s&-&read-time conditional\cr
  415. % Page&\s&.&read-time evaluation\cr
  416. % Return&\s&/&\u\cr
  417. % Space&\s&A, a&array\cr
  418. % !&\u*&B, b&binary rational\cr
  419. % \f{"}&\u&C, c&complex number\cr
  420. % \#&reference to = label&D, d&\u\cr
  421. % \$&\u&E, e&\u\cr
  422. % \%&\u&F, f&\u\cr
  423. % \&&\u&G, g&\u\cr
  424. % '&function abbreviation&H, h&\u\cr
  425. % (&simple vector&I, i&\u\cr
  426. % )&\s&J, j&\u\cr
  427. % {\tt *}&bit vector&K, k&\u\cr
  428. % ,&\u&L, l&\u\cr
  429. % :&uninterned symbol&M, m&\u\cr
  430. % ;&\u&N, n&\u\cr
  431. % \f{<}&\s&O, o&octal rational\cr
  432. % \f{=}&labels following object&P, p&pathname\cr
  433. % \f{>}&\u&Q, q&\u\cr
  434. % ?&\u*&R, r&radix-$n$ rational\cr
  435. % @&\u&S, s&structure\cr
  436. % [&\u*&T, t&\u\cr
  437. % \f{\\}&character object&U, u&\u\cr
  438. % ]&\u*&V, v&\u\cr
  439. % {\hat}&\u&W, w&\u\cr
  440. % \f{\_}&\u&X, x&hexadecimal rational\cr
  441. % `&\u&Y, y&\u\cr
  442. % \f{|}&balanced comment&Z, z&\u\cr
  443. % \f{~}&\u&Rubout&\u\cr
  444. % \noalign{\vskip -9pt}
  445. % }}
  446. % \caption{Standard \# Dispatching Macro Character Syntax}
  447. % \endfig
  448. {\def\u{undefined}
  449. \def\s{signals error}
  450. \def\ia{infix argument}
  451. \tablefigfour{Standard \# Dispatching Macro Character Syntax}{dispatch char}{purpose}{dispatch char}{purpose}{
  452. Backspace&\s&\f{\{}&\u*\cr
  453. Tab&\s&\f{\}}&\u*\cr
  454. Newline&\s&+&read-time conditional\cr
  455. Linefeed&\s&-&read-time conditional\cr
  456. Page&\s&.&read-time evaluation\cr
  457. Return&\s&/&\u\cr
  458. Space&\s&A, a&array\cr
  459. !&\u*&B, b&binary rational\cr
  460. \f{"}&\u&C, c&complex number\cr
  461. \#&reference to = label&D, d&\u\cr
  462. \$&\u&E, e&\u\cr
  463. \%&\u&F, f&\u\cr
  464. \&&\u&G, g&\u\cr
  465. '&function abbreviation&H, h&\u\cr
  466. (&simple vector&I, i&\u\cr
  467. )&\s&J, j&\u\cr
  468. {\tt *}&bit vector&K, k&\u\cr
  469. ,&\u&L, l&\u\cr
  470. :&uninterned symbol&M, m&\u\cr
  471. ;&\u&N, n&\u\cr
  472. \f{<}&\s&O, o&octal rational\cr
  473. \f{=}&labels following object&P, p&pathname\cr
  474. \f{>}&\u&Q, q&\u\cr
  475. ?&\u*&R, r&radix-$n$ rational\cr
  476. @&\u&S, s&structure\cr
  477. [&\u*&T, t&\u\cr
  478. \f{\\}&character object&U, u&\u\cr
  479. ]&\u*&V, v&\u\cr
  480. {\hat}&\u&W, w&\u\cr
  481. \f{\_}&\u&X, x&hexadecimal rational\cr
  482. `&\u&Y, y&\u\cr
  483. \f{|}&balanced comment&Z, z&\u\cr
  484. \f{~}&\u&Rubout&\u\cr
  485. }}
  486. %* The combinations marked by an asterisk are explicitly reserved to the
  487. % user and will never be defined by the \clisp\ standard.
  488. The combinations marked by an asterisk (*) are explicitly reserved to the
  489. user. No \term{conforming implementation} defines them.
  490. Note also that \term{digits} do not appear in the preceding table. This is
  491. because the notations {\tt \#0}, {\tt \#1}, ..., {\tt \#9} are
  492. reserved for another purpose which occupies the same syntactic space.
  493. When a \term{digit} follows a \term{sharpsign},
  494. it is not treated as a dispatch character.
  495. Instead, an unsigned integer argument is accumulated
  496. and passed as an \term{argument} to the \term{reader macro}
  497. for the \term{character} that follows the digits.
  498. For example,
  499. \f{\#2A((1 2) (3 4))} is a use of {\tt \#A} with an argument of \f{2}.
  500. %% 1.2.7 13
  501. %% 22.1.4 5
  502. \beginsubsubsection{Sharpsign Backslash}
  503. \DefineSection{SharpsignBackslash}
  504. \idxtext{Sharpsign Backslash (reader macro)}\idxtext{Backslash (sharpsign reader macro)}\idxref{character}
  505. \b{Syntax:} \f{\#\\\metaparam{x}}
  506. %% 2.2.0 3
  507. When the \term{token} \param{x} is a single \term{character} long,
  508. this parses as the literal \term{character} \param{char}.
  509. %% 22.1.4 7
  510. \term{Uppercase} and \term{lowercase} letters are distinguished after \f{\#\\};
  511. \f{\#\\A} and \f{\#\\a} denote different \term{character} \term{objects}.
  512. Any single \term{character} works after \f{\#\\},
  513. even those that are normally special to \funref{read},
  514. such as \term{left-parenthesis} and \term{right-parenthesis}.
  515. %% 22.1.4 6
  516. In the single \term{character} case,
  517. the \param{x} must be followed by a non-constituent \term{character}.
  518. After \f{\#\\} is read,
  519. the reader backs up over the \term{slash} and then reads a \term{token},
  520. treating the initial \term{slash} as a \term{single escape} \term{character}
  521. (whether it really is or not in the \term{current readtable}).
  522. % When the \term{token} \param{x} is more than one \term{character} long,
  523. % %% 22.1.4 8
  524. % the \param{x} has the syntax of a \term{symbol},
  525. % and the \term{sharpsign} \term{backslash} notation
  526. % parses as the \term{character} whose \term{name} is \f{(string-upcase \param{x})};
  527. % \seesection\CharacterNames.
  528. When the \term{token} \param{x} is more than one \term{character} long,
  529. %% 22.1.4 8
  530. the \param{x} must have the syntax of a \term{symbol}
  531. with no embedded \term{package markers}.
  532. In this case, the \term{sharpsign} \term{backslash} notation
  533. parses as the \term{character} whose \term{name} is \f{(string-upcase \param{x})};
  534. \seesection\CharacterNames.
  535. \issue{CHARACTER-PROPOSAL:2-1-1}
  536. \issue{CHARACTER-LOOSE-ENDS:FIX}
  537. %% 22.1.4 18
  538. %% 2.2.4 2
  539. % Discussion of #n\x notation for font n removed.
  540. %% 2.2.4 3
  541. %%% 22.1.4 17
  542. % Discussion of bits \term{attribute} and stuff like #\Control-Meta-Return removed.
  543. \endissue{CHARACTER-LOOSE-ENDS:FIX}
  544. \endissue{CHARACTER-PROPOSAL:2-1-1}
  545. For information about how the \term{Lisp printer} prints \term{character} \term{objects},
  546. \seesection\PrintingCharacters.
  547. \endsubsubsection%{Sharpsign Backslash}
  548. \beginsubsubsection{Sharpsign Single-Quote}
  549. \DefineSection{SharpsignQuote}
  550. \idxtext{Sharpsign Single-Quote (reader macro)}\idxtext{Single-Quote (sharpsign reader macro)}\idxref{function}
  551. %% 22.1.4 19
  552. %% 7.1.1 10
  553. % %\f{\#'\param{foo}} is an abbreviation for \f{(function \param{foo})}.
  554. % Any form \param{f} preceded by \f{\#'} (\f{\#} followed by an apostrophe)
  555. % is assumed to have \f{(function)} wrapped around it to make
  556. % {\tt (function \param{f})}. For example,
  557. Any \param{expression} preceded by \f{\#'}
  558. (\term{sharpsign} followed by \term{single-quote}),
  559. as in \f{\#'\param{expression}},
  560. is treated by the \term{Lisp reader} as an abbreviation for and parsed identically
  561. to the \term{expression} \f{(function \param{expression})}.
  562. See \specref{function}. For example,
  563. \code
  564. (apply #'+ l) \EQ (apply (function +) l)
  565. \endcode
  566. \endsubsubsection%{Sharpsign Single-Quote}
  567. \beginsubsubsection{Sharpsign Left-Parenthesis}
  568. \DefineSection{SharpsignLeftParen}
  569. \idxtext{Sharpsign Left-Parenthesis (reader macro)}\idxtext{Left-Parenthesis (sharpsign reader macro)}\idxref{vector}\idxref{simple-vector}
  570. %% 2.5.1 2
  571. %% 22.1.4 20
  572. \f{\#(} and \f{)} are used to notate a \term{simple vector}.
  573. %% 22.1.4 21
  574. If an unsigned decimal integer
  575. appears between the \f{\#} and \f{(},
  576. it specifies explicitly the length of the \term{vector}.
  577. The consequences are undefined if the number of \term{objects}
  578. specified before the closing \f{)}
  579. exceeds the unsigned decimal integer.
  580. If the number of \term{objects} supplied before the closing \f{)}
  581. is less than the unsigned decimal integer but greater than zero,
  582. the last \term{object}
  583. is used to fill all
  584. remaining elements of the \term{vector}.
  585. \editornote{Barmar: This should say "signals...".}
  586. The consequences are undefined if the unsigned decimal integer is non-zero and
  587. number of \term{objects} supplied before the closing \f{)}
  588. is zero.
  589. For example,
  590. \code
  591. #(a b c c c c)
  592. #6(a b c c c c)
  593. #6(a b c)
  594. #6(a b c c)
  595. \endcode
  596. all mean the same thing: a \term{vector} of length \f{6}
  597. with \term{elements} \f{a}, \f{b}, and four occurrences of \f{c}.
  598. Other examples follow:
  599. \code
  600. #(a b c) ;A vector of length 3
  601. #(2 3 5 7 11 13 17 19 23 29 31 37 41 43 47)
  602. ;A vector containing the primes below 50
  603. #() ;An empty vector
  604. \endcode
  605. The notation \f{\#()} denotes an empty \term{vector}, as does \f{\#0()}.
  606. For information on how the \term{Lisp printer} prints \term{vectors},
  607. see \secref\PrintingStrings,
  608. \secref\PrintingBitVectors,
  609. or \secref\PrintingOtherVectors.
  610. \endsubsubsection%{Sharpsign Left-Parenthesis}
  611. \beginsubsubsection{Sharpsign Asterisk}
  612. \DefineSection{SharpsignStar}
  613. \idxtext{Sharpsign Asterisk (reader macro)}\idxtext{Asterisk (sharpsign reader macro)}\idxref{bit-vector}\idxref{simple-bit-vector}
  614. %% 22.1.4 22
  615. %% 2.5.3 1
  616. \b{Syntax:} \f{\#*\metaparam{bits}}
  617. %% 2.5.3 2
  618. A \term{simple bit vector} is constructed containing the indicated \term{bits}
  619. (\f{0}'s and \f{1}'s), where the leftmost \param{bit} has index zero
  620. and the subsequent \param{bits} have increasing indices.
  621. \b{Syntax:} \f{\#\metaparam{n}*\metaparam{bits}}
  622. %% 22.1.4 23
  623. With an argument \param{n},
  624. the \term{vector} to be created is of \term{length} \param{n}.
  625. If the number of \param{bits} is less than \param{n} but greater than zero,
  626. the last bit is used to fill all remaining bits of the \term{bit vector}.
  627. The notations \f{\#*} and \f{\#0*} each denote an empty \term{bit vector}.
  628. \issue{SHARP-STAR-DELIMITER:NORMAL-DELIMITER}
  629. Regardless of whether the optional numeric argument \param{n} is provided,
  630. the \term{token} that follows the \term{asterisk} is delimited by
  631. a normal \term{token} delimiter.
  632. However, (unless \thevalueof{*read-suppress*} is \term{true})
  633. an error \oftype{reader-error} is signaled
  634. if that \term{token} is not composed entirely of \f{0}'s and \f{1}'s,
  635. or if \param{n} was supplied
  636. and the \term{token} is composed of more than \param{n} \param{bits},
  637. or if \param{n} is greater than one, but no \param{bits} were specified.
  638. Neither a \term{single escape} nor a \term{multiple escape} is permitted in this \term{token}.
  639. \endissue{SHARP-STAR-DELIMITER:NORMAL-DELIMITER}
  640. For information on how the \term{Lisp printer} prints \term{bit vectors},
  641. \seesection\PrintingBitVectors.
  642. \beginsubsubsubsection{Examples of Sharpsign Asterisk}
  643. For example,
  644. \code
  645. #*101111
  646. #6*101111
  647. #6*101
  648. #6*1011
  649. \endcode
  650. all mean the same thing: a \term{vector} of length \f{6}
  651. with \term{elements} \f{1}, \f{0}, \f{1}, \f{1}, \f{1}, and \f{1}.
  652. For example:
  653. \code
  654. #* ;An empty bit-vector
  655. \endcode
  656. \endsubsubsubsection%{Examples of Sharpsign Asterisk}
  657. \endsubsubsection%{Sharpsign Asterisk}
  658. \beginsubsubsection{Sharpsign Colon}
  659. \DefineSection{SharpsignColon}
  660. \idxtext{Sharpsign Colon (reader macro)}\idxtext{Colon (sharpsign reader macro)}\idxref{symbol}
  661. %% 22.1.4 24
  662. % \f{\#:\param{foo}} denotes an \term{uninterned} \term{symbol}
  663. % whose \term{name} is \param{foo}.
  664. % Every time this syntax is encountered,
  665. % a \term{distinct} \term{uninterned} \term{symbol} is created.
  666. % \f{\#:} requires \param{foo} to have the syntax of a
  667. % \term{symbol} name with no embedded \term{package markers}.
  668. %% Replaced:
  669. \b{Syntax:} \f{\#:\metaparam{symbol-name}}
  670. \f{\#:} introduces an \term{uninterned} \term{symbol} whose \term{name}
  671. is \param{symbol-name}. Every time this syntax is encountered,
  672. a \term{distinct} \term{uninterned} \term{symbol} is created.
  673. The \param{symbol-name} must have the syntax of a \term{symbol}
  674. with no \term{package prefix}.
  675. For information on how the \term{Lisp reader}
  676. prints \term{uninterned} \term{symbols},
  677. \seesection\PrintingSymbols.
  678. \endsubsubsection%{Sharpsign Colon}
  679. \beginsubsubsection{Sharpsign Dot}
  680. \DefineSection{SharpsignDot}
  681. \idxtext{Sharpsign Dot (reader macro)}\idxtext{Dot (sharpsign reader macro)}\idxref{eval}\idxref{*read-eval*}
  682. %% 22.1.4 25
  683. \f{\#.\param{foo}} is read as the \term{object} resulting from the evaluation
  684. of the \term{object} represented by \param{foo}.
  685. The evaluation is done during the \funref{read} process,
  686. when the \f{\#.} notation is encountered.
  687. The \f{\#.} syntax therefore performs a read-time evaluation of \param{foo}.
  688. The normal effect of {\tt \#.} is inhibited when \thevalueof{*read-eval*} is \term{false}.
  689. %Barmar asked what error type gets signaled. I made it be PARSE-ERROR. -kmp 17-Oct-90
  690. %Oops. READER-ERROR. -kmp 15-Jan-91
  691. \issue{PARSE-ERROR-STREAM:SPLIT-TYPES}
  692. In that situation, an error \oftype{reader-error} is signaled.
  693. \endissue{PARSE-ERROR-STREAM:SPLIT-TYPES}
  694. %% 22.1.4 26
  695. For an \term{object}
  696. that does not have a convenient printed
  697. representation, a \term{form} that computes the \term{object} can be given using
  698. the \f{\#.} notation.
  699. \issue{SHARP-COMMA-CONFUSION:REMOVE}
  700. %% issue here
  701. %The following will be deleted.
  702. %
  703. %or {\tt \#,}.
  704. %End of deletion.
  705. \endissue{SHARP-COMMA-CONFUSION:REMOVE}
  706. \endsubsubsection%{Sharpsign Dot}
  707. \issue{SHARP-COMMA-CONFUSION:REMOVE}
  708. %% 22.1.4 27
  709. %\beginsubsubsection{Sharpsign Comma}
  710. % Discussion of Sharpsign Comma removed here.
  711. %\endsubsubsection%{Sharpsign Comma}
  712. \endissue{SHARP-COMMA-CONFUSION:REMOVE}
  713. \beginsubsubsection{Sharpsign B}
  714. \DefineSection{SharpsignB}
  715. \idxtext{Sharpsign B (reader macro)}\idxtext{B (sharpsign reader macro)}\idxref{*read-base*}
  716. %% 22.1.4 28
  717. \f{\#B}\param{rational} reads \param{rational} in binary (radix 2).
  718. For example,
  719. \code
  720. #B1101 \EQ 13 ;1101\ssst
  721. #b101/11 \EQ 5/3
  722. \endcode
  723. \issue{SHARP-O-FOOBAR:CONSEQUENCES-UNDEFINED}
  724. The consequences are undefined if the token immediately following
  725. the \f{\#B} does not have the syntax of a binary (\ie radix 2) \term{rational}.
  726. \endissue{SHARP-O-FOOBAR:CONSEQUENCES-UNDEFINED}
  727. \endsubsubsection%{Sharpsign B}
  728. \beginsubsubsection{Sharpsign O}
  729. \DefineSection{SharpsignO}
  730. \idxtext{Sharpsign O (reader macro)}\idxtext{O (sharpsign reader macro)}\idxref{*read-base*}
  731. %% 22.1.4 29
  732. \f{\#O}\param{rational} reads \param{rational} in octal (radix 8).
  733. For example,
  734. \code
  735. #o37/15 \EQ 31/13
  736. #o777 \EQ 511
  737. #o105 \EQ 69 ;105\ssse
  738. \endcode
  739. \issue{SHARP-O-FOOBAR:CONSEQUENCES-UNDEFINED}
  740. The consequences are undefined if the token immediately following
  741. the \f{\#O} does not have the syntax of an octal (\ie radix 8) \term{rational}.
  742. \endissue{SHARP-O-FOOBAR:CONSEQUENCES-UNDEFINED}
  743. \endsubsubsection%{Sharpsign O}
  744. \beginsubsubsection{Sharpsign X}
  745. \DefineSection{SharpsignX}
  746. \idxtext{Sharpsign X (reader macro)}\idxtext{X (sharpsign reader macro)}\idxref{*read-base*}
  747. %% 22.1.4 30
  748. \f{\#X}\param{rational} reads \param{rational} in hexadecimal (radix 16).
  749. The digits above \f{9} are the letters \f{A} through \f{F} (the lowercase
  750. letters \f{a} through \f{f} are also acceptable). For example,
  751. \code
  752. #xF00 \EQ 3840
  753. #x105 \EQ 261 ;105\ssss
  754. \endcode
  755. \issue{SHARP-O-FOOBAR:CONSEQUENCES-UNDEFINED}
  756. The consequences are undefined if the token immediately following
  757. the \f{\#X} does not have the syntax of a hexadecimal (\ie radix 16) \term{rational}.
  758. \endissue{SHARP-O-FOOBAR:CONSEQUENCES-UNDEFINED}
  759. \endsubsubsection%{Sharpsign X}
  760. \beginsubsubsection{Sharpsign R}
  761. \DefineSection{SharpsignR}
  762. \idxtext{Sharpsign R (reader macro)}\idxtext{R (sharpsign reader macro)}\idxref{*read-base*}
  763. %% 22.1.4 31
  764. \f{\#\param{n}R}
  765. \f{\#\param{radix}R\param{rational}} reads \param{rational} in radix \param{radix}.
  766. \param{radix} must consist of only digits
  767. that are interpreted as an \term{integer}
  768. in decimal radix; its value must be between 2 and 36 (inclusive).
  769. Only valid digits
  770. for the specified radix may be used.
  771. %% 22.1.4 32
  772. For example, \f{\#3r102} is another way of writing \f{11} (decimal),
  773. and \f{\#11R32}
  774. is another way of writing \f{35} (decimal).
  775. For radices larger than 10, letters of
  776. the alphabet are used in order for the digits after \f{9}.
  777. No alternate \f{\#} notation exists for the decimal radix since a
  778. decimal point suffices.
  779. \Thenextfigure\ contains examples of the use of {\tt\#B},
  780. {\tt \#O}, {\tt \#X}, and {\tt \#R}.
  781. \showtwo{Radix Indicator Example}{
  782. \f{\#2r11010101} & ;Another way of writing \f{213} decimal \cr
  783. \f{\#b11010101} & ;Ditto \cr
  784. \f{\#b+11010101} & ;Ditto \cr
  785. \f{\#o325} & ;Ditto, in octal radix \cr
  786. \f{\#xD5} & ;Ditto, in hexadecimal radix \cr
  787. \f{\#16r+D5} & ;Ditto \cr
  788. \f{\#o-300} & ;Decimal \f{-192}, written in base 8 \cr
  789. \f{\#3r-21010} & ;Same thing in base 3 \cr
  790. \f{\#25R-7H} & ;Same thing in base 25 \cr
  791. \f{\#xACCEDED} & ;\f{181202413}, in hexadecimal radix \cr
  792. }
  793. \issue{SHARP-O-FOOBAR:CONSEQUENCES-UNDEFINED}
  794. The consequences are undefined if the token immediately following
  795. the \f{\#\param{n}R} does not have the syntax of a \term{rational} in radix \param{n}.
  796. \endissue{SHARP-O-FOOBAR:CONSEQUENCES-UNDEFINED}
  797. \endsubsubsection%{Sharpsign R}
  798. \beginsubsubsection{Sharpsign C}
  799. \DefineSection{SharpsignC}
  800. \idxtext{Sharpsign C (reader macro)}\idxtext{C (sharpsign reader macro)}\idxref{complex}
  801. \issue{READ-SUPPRESS-CONFUSING:GENERALIZE}
  802. % \f{\#C} followed by a \term{list} of the real and imaginary parts denotes
  803. % a \term{complex} number.
  804. \f{\#C} reads a following \term{object}, which must be a \term{list} of
  805. length two whose \term{elements} are both \term{reals}.
  806. These \term{reals} denote, respectively,
  807. the real and imaginary parts of a \term{complex} number.
  808. \endissue{READ-SUPPRESS-CONFUSING:GENERALIZE}
  809. %% 2.1.4 2
  810. If the two parts as notated are not of the same data type,
  811. then they are converted
  812. according to the rules of floating-point \term{contagion}
  813. described in \secref\NumericContagionRules.
  814. \f{\#C(\param{real} \param{imag})} is equivalent to
  815. \f{\#.(complex (quote \param{real}) (quote \param{imag}))},
  816. % I added this next phrase for clarity. -kmp 23-Aug-93
  817. except that \f{\#C} is not affected by \varref{*read-eval*}.
  818. \Seefun{complex}.
  819. \Thenextfigure\ contains examples of the use of {\tt \#C}.
  820. \showtwo{Complex Number Example}{
  821. \f{\#C(3.0s1 2.0s-1)} & ;A \term{complex} with \term{small float} parts. \cr
  822. \f{\#C(5 -3) } & ;A ``Gaussian integer'' \cr
  823. \f{\#C(5/3 7.0) } & ;Will be converted internally to \f{\#C(1.66666 7.0)} \cr
  824. \f{\#C(0 1)} & ;The imaginary unit; that is, i. \cr
  825. }
  826. For further information,
  827. \seesection\PrintingComplexes\ and \secref\SyntaxOfComplexes.
  828. \endsubsubsection%{Sharpsign C}
  829. \beginsubsubsection{Sharpsign A}
  830. \DefineSection{SharpsignA}
  831. \idxtext{Sharpsign A (reader macro)}\idxtext{A (sharpsign reader macro)}\idxref{array}
  832. %% 22.1.4 33
  833. \f{\#\param{n}A}
  834. \f{\#\param{n}\f{A}\param{object}} constructs an \param{n}-dimensional \term{array},
  835. using \param{object} as the value of the \kwd{initial-contents} argument
  836. to \funref{make-array}.
  837. %% 22.1.4 34
  838. For example, \f{\#2A((0 1 5) (foo 2 (hot dog)))} represents a 2-by-3 matrix:
  839. \code
  840. 0 1 5
  841. foo 2 (hot dog)
  842. \endcode
  843. In contrast, \f{\#1A((0 1 5) (foo 2 (hot dog)))}
  844. represents a \term{vector} of \term{length} \f{2}
  845. whose \term{elements} are \term{lists}:
  846. \code
  847. (0 1 5) (foo 2 (hot dog))
  848. \endcode
  849. \f{\#0A((0 1 5) (foo 2 (hot dog)))} represents a zero-dimensional
  850. \term{array} whose sole element is a \term{list}:
  851. \code
  852. ((0 1 5) (foo 2 (hot dog)))
  853. \endcode
  854. \f{\#0A foo} represents
  855. a zero-dimensional \term{array} whose sole element is the
  856. \term{symbol} \f{foo}.
  857. The notation \f{\#1A foo} is not valid because \f{foo} is
  858. not a \term{sequence}.
  859. If some \term{dimension} of the \term{array}
  860. whose representation is being parsed is found to be \f{0},
  861. all \term{dimensions} to the right
  862. (\ie the higher numbered \term{dimensions})
  863. are also considered to be \f{0}.
  864. For information on how the \term{Lisp printer} prints \term{arrays},
  865. see \secref\PrintingStrings,
  866. \secref\PrintingBitVectors,
  867. \secref\PrintingOtherVectors,
  868. or \secref\PrintingOtherArrays.
  869. \endsubsubsection%{Sharpsign A}
  870. \beginsubsubsection{Sharpsign S}
  871. \DefineSection{SharpsignS}
  872. \idxtext{Sharpsign S (reader macro)}\idxtext{S (sharpsign reader macro)}\idxref{structure}
  873. %% 22.1.4 35
  874. \f{\#s(name slot1 value1 slot2 value2 ...)}
  875. denotes a \term{structure}. This is valid only if \param{name} is the name
  876. of a \term{structure} \term{type} already defined by \macref{defstruct}
  877. and if the \term{structure} \term{type} has a standard constructor function.
  878. Let \param{cm} stand for the name of this constructor function;
  879. then this syntax is equivalent to
  880. \code
  881. #.(cm keyword1 'value1 keyword2 'value2 ...)
  882. \endcode
  883. where each \param{keywordj} is the result of computing
  884. \code
  885. (intern (string slotj) (find-package 'keyword))
  886. \endcode
  887. The net effect is that the constructor function is called with the specified
  888. slots having the specified values.
  889. \issue{STRUCTURE-READ-PRINT-SYNTAX:KEYWORDS}
  890. (This coercion feature is deprecated; in the future, keyword names will
  891. be taken in the package they are read in, so \term{symbols} that are
  892. actually in \thepackage{keyword} should be used if that is what is desired.)
  893. \endissue{STRUCTURE-READ-PRINT-SYNTAX:KEYWORDS}
  894. Whatever \term{object} the constructor function returns
  895. is returned by the \f{\#S} syntax.
  896. For information on how the \term{Lisp printer} prints \term{structures},
  897. \seesection\PrintingStructures.
  898. \endsubsubsection%{Sharpsign S}
  899. \beginsubsubsection{Sharpsign P}
  900. \DefineSection{SharpsignP}
  901. \idxtext{Sharpsign P (reader macro)}\idxtext{P (sharpsign reader macro)}\idxref{pathname}
  902. \issue{PATHNAME-PRINT-READ:SHARPSIGN-P}
  903. \f{\#P} reads a following \term{object}, which must be a \term{string}.
  904. % {\tt \#P"..."} is equivalent to
  905. % {\tt \#.(parse-namestring "...")}.
  906. \f{\#P\metaparam{expression}} is equivalent to
  907. \f{\#.(parse-namestring '\metaparam{expression})},
  908. % I added this next phrase for clarity. -kmp 23-Aug-93
  909. except that \f{\#P} is not affected by \varref{*read-eval*}.
  910. For information on how the \term{Lisp printer} prints \term{pathnames},
  911. see \secref\PrintingPathnames.
  912. \endissue{PATHNAME-PRINT-READ:SHARPSIGN-P}
  913. \endsubsubsection%{Sharpsign P}
  914. \beginsubsubsection{Sharpsign Equal-Sign}
  915. \idxtext{Sharpsign Equal-Sign (reader macro)}\idxtext{Equal-Sign (sharpsign reader macro)}\idxref{*print-circle*}
  916. %% 22.1.4 36
  917. \f{\#\param{n}=}
  918. \f{\#\param{n}=\param{object}} reads as whatever \term{object}
  919. has \param{object} as its printed representation. However, that \term{object}
  920. is labeled by \param{n}, a required unsigned decimal integer, for
  921. possible reference by the syntax \f{\#\param{n}\#}.
  922. The scope of the label is the \term{expression} being read by the outermost
  923. call to \funref{read}; within this \term{expression},
  924. the same label may not appear twice.
  925. \endsubsubsection%{Sharpsign Equal-Sign}
  926. \beginsubsubsection{Sharpsign Sharpsign}
  927. \idxtext{Sharpsign Sharpsign (reader macro)}\idxtext{Sharpsign (sharpsign reader macro)}\idxref{*print-circle*}
  928. %% 22.1.4 37
  929. \f{\#\param{n}\#}
  930. \f{\#\param{n}\#}, where \param{n} is a required unsigned decimal
  931. \term{integer},
  932. provides a reference to some \term{object} labeled by \f{\#\param{n}=};
  933. that is, \f{\#\param{n}\#} represents a pointer to the same
  934. (\funref{eq}) \term{object} labeled by \f{\#\param{n}=}.
  935. For example, a structure created in the variable \f{y} by this code:
  936. \code
  937. (setq x (list 'p 'q))
  938. (setq y (list (list 'a 'b) x 'foo x))
  939. (rplacd (last y) (cdr y))
  940. \endcode
  941. could be represented in this way:
  942. \code
  943. ((a b) . #1=(#2=(p q) foo #2# . #1#))
  944. \endcode
  945. Without this notation, but with \varref{*print-length*} set to \f{10}
  946. and \varref{*print-circle*} set to \nil,
  947. the structure would print in this way:
  948. \code
  949. ((a b) (p q) foo (p q) (p q) foo (p q) (p q) foo (p q) ...)
  950. \endcode
  951. A reference \f{\#\param{n}\#} may only occur after a label \f{\#\param{n}=};
  952. forward references are not permitted. The reference
  953. may not appear as the labeled object itself (that is,
  954. \f{\#\param{n}=\#\param{n}\#}) may not be written
  955. because the \term{object}
  956. labeled by \f{\#\param{n}=} is not well defined in this case.
  957. \endsubsubsection%{Sharpsign Sharpsign}
  958. \beginsubsubsection{Sharpsign Plus}
  959. \idxtext{Sharpsign Plus (reader macro)}\idxtext{Plus (sharpsign reader macro)}\idxref{*features*}
  960. %% 22.1.4 38
  961. \f{\#+} provides a read-time conditionalization facility;
  962. the syntax is \f{\#+\param{test} \param{expression}}.
  963. If the \term{feature expression} \param{test} succeeds,
  964. then this textual notation represents an \term{object}
  965. whose printed representation is \param{expression}.
  966. If the \term{feature expression} \param{test} fails,
  967. then this textual notation is treated as \term{whitespace}\meaning{2};
  968. that is, it is as if the ``\f{\#+} \param{test} \param{expression}''
  969. did not appear and only a \term{space} appeared in its place.
  970. %% 22.1.4 39
  971. For a detailed description of success and failure in \term{feature expressions},
  972. \seesection\FeatureExpressions.
  973. %% 22.1.4 42
  974. \f{\#+} operates by first reading the \term{feature expression}
  975. and then skipping over the \param{form} if the \term{feature expression} fails.
  976. \issue{SHARPSIGN-PLUS-MINUS-PACKAGE:KEYWORD}
  977. While reading the \param{test}, the \term{current package} is \thepackage{keyword}.
  978. \endissue{SHARPSIGN-PLUS-MINUS-PACKAGE:KEYWORD}
  979. Skipping over the \param{form} is accomplished by \term{binding}
  980. \varref{*read-suppress*} to \term{true} and then calling \funref{read}.
  981. For examples, \seesection\FeatureExpExamples.
  982. \endsubsubsection%{Sharpsign Plus}
  983. \beginsubsubsection{Sharpsign Minus}
  984. \idxtext{Sharpsign Minus (reader macro)}\idxtext{Minus (sharpsign reader macro)}\idxref{*features*}
  985. %% 22.1.4 43
  986. \f{\#-} is like \f{\#+}
  987. except that it skips the \param{expression} if the \param{test} succeeds;
  988. that is,
  989. \code
  990. #-\param{test} \param{expression} \EQ #+(not \param{test}) \param{expression}
  991. \endcode
  992. For examples, \seesection\FeatureExpExamples.
  993. \endsubsubsection%{Sharpsign Minus}
  994. \beginsubsubsection{Sharpsign Vertical-Bar}
  995. \idxtext{Sharpsign Vertical-Bar (reader macro)}\idxtext{Vertical-Bar (sharpsign reader macro)}\idxtext{comment}
  996. %% 22.1.4 44
  997. \f{\#|...|\#} is treated as a comment by the reader.
  998. It must be balanced with respect to other occurrences of \f{\#|} and \f{|\#},
  999. but otherwise may contain any characters whatsoever.
  1000. \beginsubsubsubsection{Examples of Sharpsign Vertical-Bar}
  1001. The following are some examples that exploit the \f{\#|...|\#} notation:
  1002. \code
  1003. ;;; In this example, some debugging code is commented out with #|...|#
  1004. ;;; Note that this kind of comment can occur in the middle of a line
  1005. ;;; (because a delimiter marks where the end of the comment occurs)
  1006. ;;; where a semicolon comment can only occur at the end of a line
  1007. ;;; (because it comments out the rest of the line).
  1008. (defun add3 (n) #|(format t "~&Adding 3 to ~D." n)|# (+ n 3))
  1009. \goodbreak
  1010. ;;; The examples that follow show issues related to #| ... |# nesting.
  1011. ;;; In this first example, #| and |# always occur properly paired,
  1012. ;;; so nesting works naturally.
  1013. (defun mention-fun-fact-1a ()
  1014. (format t "CL uses ; and #|...|# in comments."))
  1015. \EV MENTION-FUN-FACT-1A
  1016. (mention-fun-fact-1a)
  1017. \OUT CL uses ; and #|...|# in comments.
  1018. \EV NIL
  1019. #| (defun mention-fun-fact-1b ()
  1020. (format t "CL uses ; and #|...|# in comments.")) |#
  1021. (fboundp 'mention-fun-fact-1b) \EV NIL
  1022. \goodbreak
  1023. ;;; In this example, vertical-bar followed by sharpsign needed to appear
  1024. ;;; in a string without any matching sharpsign followed by vertical-bar
  1025. ;;; having preceded this. To compensate, the programmer has included a
  1026. ;;; slash separating the two characters. In case 2a, the slash is
  1027. ;;; unnecessary but harmless, but in case 2b, the slash is critical to
  1028. ;;; allowing the outer #| ... |# pair match. If the slash were not present,
  1029. ;;; the outer comment would terminate prematurely.
  1030. (defun mention-fun-fact-2a ()
  1031. (format t "Don't use |\\# unmatched or you'll get in trouble!"))
  1032. \EV MENTION-FUN-FACT-2A
  1033. (mention-fun-fact-2a)
  1034. \OUT Don't use |# unmatched or you'll get in trouble!
  1035. \EV NIL
  1036. #| (defun mention-fun-fact-2b ()
  1037. (format t "Don't use |\\# unmatched or you'll get in trouble!") |#
  1038. (fboundp 'mention-fun-fact-2b) \EV NIL
  1039. \goodbreak
  1040. ;;; In this example, the programmer attacks the mismatch problem in a
  1041. ;;; different way. The sharpsign vertical bar in the comment is not needed
  1042. ;;; for the correct parsing of the program normally (as in case 3a), but
  1043. ;;; becomes important to avoid premature termination of a comment when such
  1044. ;;; a program is commented out (as in case 3b).
  1045. (defun mention-fun-fact-3a () ; #|
  1046. (format t "Don't use |# unmatched or you'll get in trouble!"))
  1047. \EV MENTION-FUN-FACT-3A
  1048. (mention-fun-fact-3a)
  1049. \OUT Don't use |# unmatched or you'll get in trouble!
  1050. \EV NIL
  1051. #|
  1052. (defun mention-fun-fact-3b () ; #|
  1053. (format t "Don't use |# unmatched or you'll get in trouble!"))
  1054. |#
  1055. (fboundp 'mention-fun-fact-3b) \EV NIL
  1056. \endcode
  1057. \endsubsubsubsection%{Examples of Sharpsign Vertical-Bar}
  1058. \beginsubsubsubsection{Notes about Style for Sharpsign Vertical-Bar}
  1059. Some text editors that purport to understand Lisp syntax treat any \f{|...|}
  1060. as balanced pairs that cannot nest (as if they were just balanced pairs of
  1061. the multiple escapes used in notating certain symbols). To compensate for
  1062. this deficiency, some programmers use the notation \f{\#||...\#||...||\#...||\#}
  1063. instead of \f{\#|...\#|...|\#...|\#}. Note that this alternate usage is not
  1064. a different \term{reader macro}; it merely exploits the fact that the additional
  1065. vertical-bars occur within the comment in a way that tricks certain text editor
  1066. into better supporting nested comments. As such, one might sometimes see code
  1067. like:
  1068. \code
  1069. #|| (+ #|| 3 ||# 4 5) ||#
  1070. \endcode
  1071. Such code is equivalent to:
  1072. \code
  1073. #| (+ #| 3 |# 4 5) |#
  1074. \endcode
  1075. \endsubsubsubsection%{Notes about Style for Sharpsign Vertical-Bar}
  1076. \endsubsubsection%{Sharpsign Vertical-Bar}
  1077. \beginsubsubsection{Sharpsign Less-Than-Sign}
  1078. \DefineSection{SharpsignLeftAngle}
  1079. \idxtext{Sharpsign Less-Than-Sign (reader macro)}\idxtext{Less-Than-Sign (sharpsign reader macro)}
  1080. %% 22.1.4 46
  1081. {\tt \#<} is not valid reader syntax.
  1082. The \term{Lisp reader} will signal an error
  1083. \issue{PARSE-ERROR-STREAM:SPLIT-TYPES}
  1084. \oftype{reader-error}
  1085. \endissue{PARSE-ERROR-STREAM:SPLIT-TYPES}
  1086. on encountering \f{\#<}.
  1087. This syntax is typically used in the printed representation
  1088. of \term{objects} that cannot be read back in.
  1089. \endsubsubsection%{Sharpsign Less-Than-Sign}
  1090. \beginsubsubsection{Sharpsign Whitespace}
  1091. \idxtext{Sharpsign Whitespace}
  1092. %% 22.1.4 47
  1093. %Used to explicitly mention Newline, Page, Return
  1094. %but those are not chars in the standard syntax. -kmp 13-May-91
  1095. \f{\#} followed immediately by \term{whitespace}\meaning{1} is not valid reader syntax.
  1096. The \term{Lisp reader} will signal an error \oftype{reader-error} if it
  1097. encounters the reader macro notation \f{\#\NewlineChar} or \f{\#\SpaceChar}.
  1098. \endsubsubsection%{Sharpsign Whitespace}
  1099. \beginsubsubsection{Sharpsign Right-Parenthesis}
  1100. \idxtext{Sharpsign Right-Parenthesis}
  1101. %% 22.1.4 48
  1102. This is not valid reader syntax.
  1103. %I added this. It's alluded to elsewhere that it really signals. -kmp 15-Jan-91
  1104. The \term{Lisp reader} will signal an error
  1105. \issue{PARSE-ERROR-STREAM:SPLIT-TYPES}
  1106. \oftype{reader-error}
  1107. \endissue{PARSE-ERROR-STREAM:SPLIT-TYPES}
  1108. %(
  1109. upon encountering \f{\#)}.
  1110. \endsubsubsection%{Sharpsign Right-Parenthesis}
  1111. \endsubsection%{Sharpsign}
  1112. \beginsubsection{Re-Reading Abbreviated Expressions}
  1113. \idxtext{Dot Dot}\idxcode{..}
  1114. \idxtext{Dot Dot Dot}\idxcode{...}
  1115. \idxtext{Sharpsign Whitespace}\idxtext{Sharpsign Right-Parenthesis}
  1116. %% 22.1.6 53
  1117. Note that the \term{Lisp reader} will
  1118. % Only generally because ".." due to print-lines in mid-string won't reliably signal.
  1119. generally
  1120. signal an error \oftype{reader-error}
  1121. when reading an \term{expression}\meaning{2} that has been
  1122. abbreviated because of length or level limits
  1123. (see \varref{*print-level*},
  1124. \varref{*print-length*},
  1125. and \varref{*print-lines*})
  1126. due to restrictions on ``\f{..}'', ``\f{...}'', ``\f{\#}'' followed by \term{whitespace}\meaning{1},
  1127. %(
  1128. and ``\f{\#)}''.
  1129. \endsubsection%{Re-Reading Abbreviated Expressions}