dict-strings.tex 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005
  1. % -*- Mode: TeX -*-
  2. % Strings
  3. %-------------------- Strings --------------------
  4. %% 2.5.2 1
  5. %% 18.0.0 3
  6. \begincom{string}\ftype{System Class}
  7. \label Class Precedence List::
  8. \typeref{string},
  9. %% 2.15.0 16
  10. \typeref{vector},
  11. \typeref{array},
  12. \typeref{sequence},
  13. \typeref{t}
  14. \label Description::
  15. \issue{CHARACTER-PROPOSAL:2-3-2}
  16. A \term{string} is a \term{specialized} \term{vector}
  17. whose \term{elements} are \oftypes{character}.
  18. When used as a \term{type specifier} for object creation,
  19. \typeref{string} means \f{(vector character)}.
  20. \endissue{CHARACTER-PROPOSAL:2-3-2}
  21. \issue{CHARACTER-PROPOSAL:2-3-3}
  22. \label Compound Type Specifier Kind::
  23. Abbreviating.
  24. \label Compound Type Specifier Syntax::
  25. %% 4.6.0 10
  26. \Deftype{string}{\ttbrac{size}}
  27. \label Compound Type Specifier Arguments::
  28. \issue{ARRAY-DIMENSION-IMPLICATIONS:ALL-FIXNUM}
  29. \param{size}---a non-negative \term{fixnum},
  30. or the \term{symbol} \misc{*}.
  31. \endissue{ARRAY-DIMENSION-IMPLICATIONS:ALL-FIXNUM}
  32. \label Compound Type Specifier Description::
  33. This denotes the union of all \term{types}
  34. \f{(array \i{c} (\param{size}))}
  35. for all \term{subtypes} \i{c} of \typeref{character};
  36. that is, the set of \term{strings} of size \param{size}.
  37. \label See Also::
  38. {\secref\StringConcepts},
  39. {\secref\Doublequote},
  40. {\secref\PrintingStrings}
  41. \endcom%{string}\ftype{System Class}
  42. \begincom{base-string}\ftype{Type}
  43. \issue{CHARACTER-PROPOSAL:2-3-3}
  44. \label Supertypes::
  45. \typeref{base-string},
  46. \typeref{string},
  47. \typeref{vector},
  48. \typeref{array},
  49. \typeref{sequence},
  50. \typeref{t}
  51. \label Description::
  52. \Thetype{base-string} is equivalent to
  53. \issue{CHARACTER-VS-CHAR:LESS-INCONSISTENT-SHORT}
  54. \f{(vector base-char)}.
  55. \endissue{CHARACTER-VS-CHAR:LESS-INCONSISTENT-SHORT}
  56. % A \term{base string} is the most efficient \term{string} that can hold
  57. % %%this next phrase added in answer to Symbolics' concerns that
  58. % %%otherwise a special representation for certain subsets of standard-char
  59. % %%might be unintentionally prohibited by the spec.
  60. % an arbitrary sequence of \term{standard characters}.
  61. %% Rewritten for Sandra to use "representation" -kmp 13-Jan-92
  62. %!!! KAB (re: "efficient") I think we never decided what this meant. True?
  63. %KMP: True.
  64. The \term{base string} representation is the most efficient \term{string} representation
  65. that can hold an arbitrary sequence of \term{standard characters}.
  66. \endissue{CHARACTER-PROPOSAL:2-3-3}
  67. %!!! Should this be said somewhere??
  68. %
  69. %\issue{CHARACTER-PROPOSAL:2-3}
  70. %An implementation can support \term{string} subtypes in addition
  71. %to the ones defined in this standard.
  72. %For example, an
  73. %implementation supporting Arabic and Cyrillic characters
  74. %might provide as extended characters:
  75. %\beginlist
  76. %\itemitem{\typeref{general-string}}
  77. %
  78. %Can contain Arabic, Cyrillic or \term{base characters}
  79. %in any mixture.
  80. %
  81. %\itemitem{\typeref{region-specialized-string}}
  82. %
  83. %Can contain installation-selected repertoire
  84. %(Arabic/Cyrillic) or \term{base characters} in any mixture.
  85. %
  86. %\itemitem{\typeref{base-string}}
  87. %
  88. %Can contain \term{base characters}.
  89. %\endlist
  90. %Though portability of applications using
  91. %\typeref{region-specialized-string} is limited, a performance
  92. %advantage might argue for its use.
  93. %
  94. %Alternatively,
  95. %an implementation
  96. %supporting a large base character repertoire
  97. %including, say, Japanese Kanji might define
  98. %\issue{CHARACTER-VS-CHAR:LESS-INCONSISTENT-SHORT}
  99. %\typeref{base-char}
  100. %\endissue{CHARACTER-VS-CHAR:LESS-INCONSISTENT-SHORT}
  101. %as equivalent to \term{character}.
  102. % %We expect that applications sensitive to the performance
  103. %%of character handling in some host environments will
  104. %%utilize the string subtypes to provide performance
  105. %%improvement. Applications with emphasis on international
  106. %%portability will likely utilize only {\clkwd general-strings}.
  107. %\term{Base strings} allow for more compact representation of
  108. %\term{strings}
  109. %of \term{base characters}, which are likely to predominate in any system.
  110. %Note that in any particular implementation the \term{base characters}
  111. %need not be the
  112. %most compactly representable, since others might have
  113. %a smaller repertoire.
  114. %However, in most implementations \term{base strings} are
  115. %likely to be more space efficient than other types of \term{strings}.
  116. %\endissue{CHARACTER-PROPOSAL:2-3}
  117. \label Compound Type Specifier Kind::
  118. Abbreviating.
  119. \label Compound Type Specifier Syntax::
  120. \issue{JUN90-TRIVIAL-ISSUES:24}
  121. \Deftype{base-string}{\ttbrac{size}}
  122. \endissue{JUN90-TRIVIAL-ISSUES:24}
  123. \label Compound Type Specifier Arguments::
  124. \issue{ARRAY-DIMENSION-IMPLICATIONS:ALL-FIXNUM}
  125. \param{size}---a non-negative \term{fixnum},
  126. or the \term{symbol} \misc{*}.
  127. \endissue{ARRAY-DIMENSION-IMPLICATIONS:ALL-FIXNUM}
  128. \label Compound Type Specifier Description::
  129. This is equivalent to the type \f{(vector base-char \param{size})};
  130. that is, the set of \term{base strings} of size \param{size}.
  131. \endissue{CHARACTER-PROPOSAL:2-3-3}
  132. \endcom%{base-string}\ftype{Type}
  133. \begincom{simple-string}\ftype{Type}
  134. \label Supertypes::
  135. \typeref{simple-string},
  136. %% 2.15.0 23
  137. \typeref{string},
  138. \typeref{vector},
  139. \typeref{simple-array},
  140. \typeref{array},
  141. \typeref{sequence},
  142. \typeref{t}
  143. \label Description::
  144. \issue{CHARACTER-PROPOSAL:2-3-4}
  145. %A \term{string} that is not displaced to another \term{array},
  146. %has no \term{fill pointer}, and is not to have its size adjusted
  147. %dynamically after creation is a \typeref{simple-string}.
  148. A \term{simple string} is a specialized one-dimensional
  149. \term{simple array} whose \term{elements} are \oftypes{character}.
  150. When used as a \term{type specifier} for object creation,
  151. \typeref{simple-string} means \f{(simple-array character (\i{size}))}.
  152. \endissue{CHARACTER-PROPOSAL:2-3-4}
  153. \label Compound Type Specifier Kind::
  154. Abbreviating.
  155. \label Compound Type Specifier Syntax::
  156. \Deftype{simple-string}{\ttbrac{size}}
  157. \label Compound Type Specifier Arguments::
  158. \issue{ARRAY-DIMENSION-IMPLICATIONS:ALL-FIXNUM}
  159. \param{size}---a non-negative \term{fixnum},
  160. or the \term{symbol} \misc{*}.
  161. \endissue{ARRAY-DIMENSION-IMPLICATIONS:ALL-FIXNUM}
  162. \label Compound Type Specifier Description::
  163. %% 4.6.0 11
  164. %\itemitem{\tt (simple-string \param{size})}
  165. This denotes the union of all \term{types}
  166. {\tt (simple-array \i{c} (\param{size}))} for all \term{subtypes} \i{c} of
  167. \typeref{character}; that is, the set of \term{simple strings} of size \param{size}.
  168. \endcom%{simple-string}\ftype{Type}
  169. \issue{CHARACTER-PROPOSAL:2-3-5}
  170. \begincom{simple-base-string}\ftype{Type}
  171. \label Supertypes::
  172. \typeref{simple-base-string},
  173. \typeref{base-string},
  174. \typeref{simple-string},
  175. \typeref{string},
  176. \typeref{vector},
  177. \typeref{simple-array},
  178. \typeref{array},
  179. \typeref{sequence},
  180. \typeref{t}
  181. \label Description::
  182. \Thetype{simple-base-string} is equivalent to
  183. \issue{CHARACTER-VS-CHAR:LESS-INCONSISTENT-SHORT}
  184. \f{(simple-array base-char (*))}.
  185. \endissue{CHARACTER-VS-CHAR:LESS-INCONSISTENT-SHORT}
  186. \endissue{CHARACTER-PROPOSAL:2-3-5}
  187. \label Compound Type Specifier Kind::
  188. Abbreviating.
  189. \label Compound Type Specifier Syntax::
  190. \issue{JUN90-TRIVIAL-ISSUES:24}
  191. \Deftype{simple-base-string}{\ttbrac{size}}
  192. \endissue{JUN90-TRIVIAL-ISSUES:24}
  193. \label Compound Type Specifier Arguments::
  194. \issue{ARRAY-DIMENSION-IMPLICATIONS:ALL-FIXNUM}
  195. \param{size}---a non-negative \term{fixnum},
  196. or the \term{symbol} \misc{*}.
  197. \endissue{ARRAY-DIMENSION-IMPLICATIONS:ALL-FIXNUM}
  198. \label Compound Type Specifier Description::
  199. This is equivalent to the type \f{(simple-array base-char (\param{size}))};
  200. that is, the set of \term{simple base strings} of size \param{size}.
  201. \endcom%{simple-base-string}\ftype{Type}
  202. %%% ========== SIMPLE-STRING-P
  203. \begincom{simple-string-p}\ftype{Function}
  204. \label Syntax::
  205. \DefunWithValues simple-string-p {object} {generalized-boolean}
  206. \label Arguments and Values::
  207. \param{object}---an \term{object}.
  208. \param{generalized-boolean}---a \term{generalized boolean}.
  209. \label Description::
  210. %% 6.2.2 22
  211. \TypePredicate{object}{simple-string}
  212. \label Examples::
  213. \code
  214. (simple-string-p "aaaaaa") \EV \term{true}
  215. (simple-string-p (make-array 6
  216. :element-type 'character
  217. :fill-pointer t)) \EV \term{false}
  218. \endcode
  219. \label Side Effects:\None.
  220. \label Affected By:\None.
  221. \label Exceptional Situations:\None!
  222. \label See Also:\None.
  223. \label Notes::
  224. \code
  225. (simple-string-p \param{object}) \EQ (typep \param{object} 'simple-string)
  226. \endcode
  227. \endcom
  228. %%% ========== CHAR
  229. %%% ========== SCHAR
  230. \begincom{char, schar}\ftype{Accessor}
  231. \label Syntax::
  232. \DefunMultiWithValues {string index} {character}
  233. {\entry{char}
  234. \entry{schar}}
  235. \DefsetfMulti {string index} {new-character}
  236. {\entry{char}
  237. \entry{schar}}
  238. \label Arguments and Values::
  239. %% 18.1.0 4
  240. \param{string}---for \funref{char}, a \term{string};
  241. for \funref{schar}, a \term{simple string}.
  242. \param{index}---a \term{valid array index} for the \param{string}.
  243. \param{character}, \param{new-character}---a \term{character}.
  244. \label Description::
  245. %% 18.1.0 3
  246. \funref{char} and \funref{schar} \term{access} the \term{element} of \param{string}
  247. specified by \param{index}.
  248. %% This is now said in the concept stuff.
  249. % \param{Index} is an offset from the beginning
  250. % of \param{string}; indexing is zero-origin.
  251. \funref{char} ignores \term{fill pointers} when \term{accessing} \term{elements}.
  252. %% KAB: Implied by "access".
  253. % \macref{setf} can be used with \funref{char} or \funref{schar}
  254. % to destructively replace an \term{element} of the \param{string}.
  255. \label Examples::
  256. \code
  257. (setq my-simple-string (make-string 6 :initial-element #\\A)) \EV "AAAAAA"
  258. (schar my-simple-string 4) \EV #\\A
  259. (setf (schar my-simple-string 4) #\\B) \EV #\\B
  260. my-simple-string \EV "AAAABA"
  261. (setq my-filled-string
  262. (make-array 6 :element-type 'character
  263. :fill-pointer 5
  264. :initial-contents my-simple-string))
  265. \EV "AAAAB"
  266. (char my-filled-string 4) \EV #\\B
  267. (char my-filled-string 5) \EV #\\A
  268. (setf (char my-filled-string 3) #\\C) \EV #\\C
  269. (setf (char my-filled-string 5) #\\D) \EV #\\D
  270. (setf (fill-pointer my-filled-string) 6) \EV 6
  271. my-filled-string \EV "AAACBD"
  272. \endcode
  273. \label Affected By:\None.
  274. \label Exceptional Situations:\None.
  275. %!!! Barrett thinks stuff belongs here.
  276. \label See Also::
  277. \funref{aref},
  278. \funref{elt},
  279. \issue{CONSTANT-MODIFICATION:DISALLOW}
  280. {\secref\ConstantModification}
  281. \endissue{CONSTANT-MODIFICATION:DISALLOW}
  282. \label Notes::
  283. \code
  284. (char s j) \EQ (aref (the string s) j)
  285. \endcode
  286. \endcom
  287. %%% ========== STRING
  288. \begincom{string}\ftype{Function}
  289. \label Syntax::
  290. \DefunWithValues string {x} {string}
  291. \label Arguments and Values::
  292. \issue{CHARACTER-PROPOSAL:2-1-1}
  293. \param{x}---a \term{string}, a \term{symbol}, or a \term{character}.
  294. \endissue{CHARACTER-PROPOSAL:2-1-1}
  295. \param{string}---a \term{string}.
  296. \label Description::
  297. Returns a \term{string} described by \param{x}; specifically:
  298. \beginlist
  299. \item{\bull} If \param{x} is a \term{string}, it is returned.
  300. \item{\bull} If \param{x} is a \term{symbol}, its \term{name} is returned.
  301. \item{\bull}
  302. \issue{CHARACTER-PROPOSAL:2-1-1}%
  303. If \param{x} is a \term{character},
  304. \endissue{CHARACTER-PROPOSAL:2-1-1}
  305. then a \term{string} containing that one \term{character} is returned.
  306. \item{\bull}
  307. \issue{STRING-COERCION:MAKE-CONSISTENT}%
  308. \funref{string} might perform additional, \term{implementation-defined} conversions.
  309. \endissue{STRING-COERCION:MAKE-CONSISTENT}
  310. \endlist
  311. \label Examples::
  312. \code
  313. (string "already a string") \EV "already a string"
  314. (string 'elm) \EV "ELM"
  315. (string #\\c) \EV "c"
  316. \endcode
  317. \label Affected By:\None.
  318. \label Exceptional Situations::
  319. \issue{STRING-COERCION:MAKE-CONSISTENT}
  320. In the case where a conversion is defined neither by this specification nor
  321. by the \term{implementation}, an error \oftype{type-error} is signaled.
  322. \endissue{STRING-COERCION:MAKE-CONSISTENT}
  323. \label See Also::
  324. \funref{coerce},
  325. \typeref{string} (\term{type}).
  326. \label Notes::
  327. %% 18.3.0 14
  328. %% KMP (13-Feb-91): Need to make it so that this is apparent and needn't be inferred
  329. %% from weird rules of thumb.
  330. %% Barmar: Do they allow a character argument?
  331. %% KMP: No! Hmm. Removed for now as misleading.
  332. % Most of the string functions effectively apply \funref{string}
  333. % to their arguments that are supposed to be \term{strings}.
  334. %% 18.3.0 15
  335. \funref{coerce} can be used to convert a \term{sequence} of \term{characters}
  336. to a \term{string}.
  337. %% 18.3.0 15
  338. \funref{prin1-to-string}, \funref{princ-to-string}, \funref{write-to-string},
  339. or \funref{format} (with a first argument of \nil) can be used to get a
  340. \term{string} representation of a \term{number} or any other \term{object}.
  341. \endcom
  342. %%% ========== NSTRING-CAPITALIZE
  343. %%% ========== NSTRING-DOWNCASE
  344. %%% ========== NSTRING-UPCASE
  345. %%% ========== STRING-CAPITALIZE
  346. %%% ========== STRING-DOWNCASE
  347. %%% ========== STRING-UPCASE
  348. \begincom{string-upcase, string-downcase, string-capitalize,
  349. nstring-upcase, nstring-downcase, nstring-capitalize}\ftype{Function}
  350. \label Syntax::
  351. \DefunMultiWithValues {string {\key} start end} {cased-string}
  352. {\entry{string-upcase}
  353. \entry{string-downcase}
  354. \entry{string-capitalize}}
  355. \DefunMultiWithValues {string {\key} start end} {string}
  356. {\entry{nstring-upcase}
  357. \entry{nstring-downcase}
  358. \entry{nstring-capitalize}}
  359. \label Arguments and Values::
  360. \issue{STRING-COERCION:MAKE-CONSISTENT}
  361. \param{string}---a \term{string designator}.
  362. For \funref{nstring-upcase},
  363. \funref{nstring-downcase},
  364. and \funref{nstring-capitalize},
  365. the \param{string} \term{designator} must be a \term{string}.
  366. \endissue{STRING-COERCION:MAKE-CONSISTENT}
  367. \issue{SUBSEQ-OUT-OF-BOUNDS}
  368. \issue{RANGE-OF-START-AND-END-PARAMETERS:INTEGER-AND-INTEGER-NIL}
  369. \param{start}, \param{end}---\term{bounding index designators} of \param{string}.
  370. \Defaults{\param{start} and \param{end}}{\f{0} and \nil}
  371. \endissue{RANGE-OF-START-AND-END-PARAMETERS:INTEGER-AND-INTEGER-NIL}
  372. \endissue{SUBSEQ-OUT-OF-BOUNDS}
  373. %% 18.3.0 13
  374. \param{cased-string}---a \term{string}.
  375. \label Description::
  376. \funref{string-upcase}, \funref{string-downcase}, \funref{string-capitalize},
  377. \funref{nstring-upcase}, \funref{nstring-downcase}, \funref{nstring-capitalize}
  378. change the case of the subsequence of \param{string}
  379. \term{bounded} by \param{start} and \param{end}
  380. as follows:
  381. \beginlist
  382. \itemitem{\bf string-upcase}
  383. %% 18.3.0 6
  384. \funref{string-upcase} returns a \term{string} just like \param{string}
  385. with all lowercase characters replaced by the corresponding uppercase
  386. characters. More precisely, each character of the result \term{string}
  387. is produced by applying \thefunction{char-upcase} to the corresponding
  388. character of \param{string}.
  389. \itemitem{\bf string-downcase}
  390. %% 18.3.0 7
  391. \funref{string-downcase} is like \funref{string-upcase}
  392. except that all uppercase characters are replaced by the corresponding
  393. lowercase characters (using \funref{char-downcase}).
  394. \itemitem{\bf string-capitalize}
  395. %% 18.3.0 10
  396. \funref{string-capitalize} produces a copy of \param{string} such that,
  397. for every word in the copy, the first \term{character} of the ``word,''
  398. if it has \term{case}, is \term{uppercase} and
  399. any other \term{characters} with \term{case} in the word are \term{lowercase}.
  400. For the purposes of \funref{string-capitalize},
  401. a ``word'' is defined to be a
  402. %% Rewritten on advice of Barmar, with confirmation from Quinquevirate.
  403. %consecutive subsequence consisting of case-modifiable characters or digits,
  404. consecutive subsequence consisting of \term{alphanumeric} \term{characters},
  405. delimited at each end either by a non-\term{alphanumeric} \term{character}
  406. or by an end of the \term{string}.
  407. %% 18.3.0 12
  408. \itemitem{\bf nstring-upcase, nstring-downcase, nstring-capitalize }
  409. %Barrett wondered if these really had to modify the string. CLtL p304 says yes. -kmp 13-Feb-92
  410. \funref{nstring-upcase}, \funref{nstring-downcase},
  411. and \funref{nstring-capitalize} are identical to \funref{string-upcase},
  412. \funref{string-downcase}, and \funref{string-capitalize}
  413. respectively except that they modify \param{string}.
  414. \endlist
  415. %% Barrett: Duplication
  416. % \param{start} marks the beginning position of the substring.
  417. % \param{end} marks the position following the last element of the substring.
  418. %% 18.3.0 9
  419. For \funref{string-upcase}, \funref{string-downcase}, and \funref{string-capitalize},
  420. \param{string} is not modified. However, if no characters in \param{string}
  421. require conversion, the result may be either \param{string} or a copy of it,
  422. at the implementation's discretion.
  423. %% Implied by use of "string designator".
  424. % \issue{STRING-COERCION:MAKE-CONSISTENT}
  425. % \funref{string-upcase}, \funref{string-downcase}, and \funref{string-capitalize}
  426. % perform coercion identical to the action of \funref{string}.
  427. % \endissue{STRING-COERCION:MAKE-CONSISTENT}
  428. \label Examples::
  429. \code
  430. (string-upcase "abcde") \EV "ABCDE"
  431. (string-upcase "Dr. Livingston, I presume?")
  432. \EV "DR. LIVINGSTON, I PRESUME?"
  433. (string-upcase "Dr. Livingston, I presume?" :start 6 :end 10)
  434. \EV "Dr. LiVINGston, I presume?"
  435. (string-downcase "Dr. Livingston, I presume?")
  436. \EV "dr. livingston, i presume?"
  437. (string-capitalize "elm 13c arthur;fig don't") \EV "Elm 13c Arthur;Fig Don'T"
  438. (string-capitalize " hello ") \EV " Hello "
  439. (string-capitalize "occlUDeD cASEmenTs FOreSTAll iNADVertent DEFenestraTION")
  440. \EV "Occluded Casements Forestall Inadvertent Defenestration"
  441. (string-capitalize 'kludgy-hash-search) \EV "Kludgy-Hash-Search"
  442. (string-capitalize "DON'T!") \EV "Don'T!" ;not "Don't!"
  443. (string-capitalize "pipe 13a, foo16c") \EV "Pipe 13a, Foo16c"
  444. (setq str (copy-seq "0123ABCD890a")) \EV "0123ABCD890a"
  445. (nstring-downcase str :start 5 :end 7) \EV "0123AbcD890a"
  446. str \EV "0123AbcD890a"
  447. \endcode
  448. \label Side Effects::
  449. \funref{nstring-upcase},
  450. \funref{nstring-downcase},
  451. and \funref{nstring-capitalize} modify \param{string} as appropriate
  452. rather than constructing a new \term{string}.
  453. \label Affected By:\None.
  454. %% Sandra thinks this is too vague.
  455. %The \term{implementation}.
  456. \label Exceptional Situations:\None.
  457. \label See Also::
  458. \funref{char-upcase}, \funref{char-downcase}
  459. \label Notes::
  460. %% 18.3.0 8
  461. The result is always of the same length
  462. as \param{string}.
  463. \endcom
  464. %%% ========== STRING-TRIM
  465. %%% ========== STRING-LEFT-TRIM
  466. %%% ========== STRING-RIGHT-TRIM
  467. \begincom{string-trim, string-left-trim, string-right-trim}\ftype{Function}
  468. \label Syntax::
  469. \DefunMultiWithValues {character-bag string} {trimmed-string}
  470. {\entry{string-trim}
  471. \entry{string-left-trim}
  472. \entry{string-right-trim}}
  473. \label Arguments and Values::
  474. \param{character-bag}---a \term{sequence} containing \term{characters}.
  475. \issue{STRING-COERCION:MAKE-CONSISTENT}
  476. \param{string}---a \term{string designator}.
  477. \endissue{STRING-COERCION:MAKE-CONSISTENT}
  478. \param{trimmed-string}---a \term{string}.
  479. \label Description::
  480. %% 18.3.0 5
  481. \funref{string-trim} returns a substring of \param{string},
  482. with all characters in \param{character-bag} stripped off the beginning and end.
  483. \funref{string-left-trim} is similar but strips characters off only the beginning;
  484. \funref{string-right-trim} strips off only the end.
  485. If no \term{characters} need to be trimmed from the \param{string},
  486. then either \param{string} itself or a copy of it may be returned,
  487. at the discretion of the implementation.
  488. %Added for Barrett.
  489. All of these \term{functions} observe the \term{fill pointer}.
  490. %% Implied by "string designator".
  491. % \issue{STRING-COERCION:MAKE-CONSISTENT}
  492. % The functions herein described perform coercion identical to the action of \funref{string}.
  493. % \endissue{STRING-COERCION:MAKE-CONSISTENT}
  494. \label Examples::
  495. \code
  496. (string-trim "abc" "abcaakaaakabcaaa") \EV "kaaak"
  497. (string-trim '(#\\Space #\\Tab #\\Newline) " garbanzo beans
  498. ") \EV "garbanzo beans"
  499. (string-trim " (*)" " ( *three (silly) words* ) ")
  500. \EV "three (silly) words"
  501. (string-left-trim "abc" "labcabcabc") \EV "labcabcabc"
  502. (string-left-trim " (*)" " ( *three (silly) words* ) ")
  503. \EV "three (silly) words* ) "
  504. (string-right-trim " (*)" " ( *three (silly) words* ) ")
  505. \EV " ( *three (silly) words"
  506. \endcode
  507. \label Side Effects:\None.
  508. \label Affected By::
  509. The \term{implementation}.
  510. \label Exceptional Situations:\None.
  511. \label See Also:\None.
  512. \label Notes:\None.
  513. \endcom
  514. %%% ========== STRING=
  515. %%% ========== STRING/=
  516. %%% ========== STRING<
  517. %%% ========== STRING>
  518. %%% ========== STRING>=
  519. %%% ========== STRING<=
  520. %%% ========== STRING-EQUAL
  521. %%% ========== STRING-NOT-EQUAL
  522. %%% ========== STRING-GREATERP
  523. %%% ========== STRING-LESSP
  524. %%% ========== STRING-NOT-LESSP
  525. %%% ========== STRING-NOT-GREATERP
  526. \begincom{string=, string/=, string<, string>, string<=, string>=,
  527. string-equal, string-not-equal, string-lessp,
  528. string-greaterp, string-not-greaterp, string-not-lessp}\ftype{Function}
  529. \label Syntax::
  530. %!!! Need to cross-check the return values here against CLtL for accuracy.
  531. % My guess is that something's been corrupted along the way. -kmp 27-May-91
  532. \DefunWithValues {string$=$}
  533. {string1 string2 {\key} start1 end1 start2 end2}
  534. {generalized-boolean}
  535. \DefunMultiWithValues {string1 string2 {\key} start1 end1 start2 end2}
  536. {mismatch-index}
  537. {\entry{string/$=$}
  538. \entry{string$<$}
  539. \entry{string$>$}
  540. \entry{string$<=$}
  541. \entry{string$>=$}}
  542. \DefunWithValues {string-equal}
  543. {string1 string2 {\key} start1 end1 start2 end2}
  544. {generalized-boolean}
  545. \DefunMultiWithValues {string1 string2 {\key} start1 end1 start2 end2}
  546. {mismatch-index}
  547. {\entry{string-not-equal}
  548. \entry{string-lessp}
  549. \entry{string-greaterp}
  550. \entry{string-not-greaterp}
  551. \entry{string-not-lessp}}
  552. \label Arguments and Values::
  553. %% 18.2.0 4
  554. %% 18.2.0 11
  555. \issue{STRING-COERCION:MAKE-CONSISTENT}
  556. \param{string1}---a \term{string designator}.
  557. \param{string2}---a \term{string designator}.
  558. \endissue{STRING-COERCION:MAKE-CONSISTENT}
  559. \issue{SUBSEQ-OUT-OF-BOUNDS}
  560. \issue{RANGE-OF-START-AND-END-PARAMETERS:INTEGER-AND-INTEGER-NIL}
  561. \param{start1}, \param{end1}---\term{bounding index designators} of \param{string1}.
  562. \Defaults{\param{start} and \param{end}}{\f{0} and \nil}
  563. \param{start2}, \param{end2}---\term{bounding index designators} of \param{string2}.
  564. \Defaults{\param{start} and \param{end}}{\f{0} and \nil}
  565. \endissue{RANGE-OF-START-AND-END-PARAMETERS:INTEGER-AND-INTEGER-NIL}
  566. \endissue{SUBSEQ-OUT-OF-BOUNDS}
  567. \param{generalized-boolean}---a \term{generalized boolean}.
  568. \param{mismatch-index}---a \term{bounding index} of \param{string1}, or \nil.
  569. \label Description::
  570. %% 18.2.0 9
  571. These functions perform lexicographic comparisons on \param{string1} and \param{string2}.
  572. \funref{string=} and \funref{string-equal} are called equality functions;
  573. the others are called inequality functions.
  574. The comparison operations these \term{functions} perform are restricted
  575. to the subsequence of \param{string1} \term{bounded} by \term{start1} and \param{end1}
  576. and to the subsequence of \param{string2} \term{bounded} by \term{start2} and \param{end2}.
  577. A string \i{a} is equal to a string \i{b} if it contains the same number
  578. of characters, and the corresponding characters are the \term{same}
  579. % "char<", "char-lessp" => "char=", "char-equal" in next line thanks to Barmar! -kmp 22-Jan-92
  580. under \funref{char=} or \funref{char-equal}, as appropriate.
  581. %% 18.2.0 10
  582. A string \i{a} is less than a string \i{b} if in the first position in
  583. which they differ the character of \i{a} is less than the corresponding
  584. character of \i{b} according to \funref{char<} or \funref{char-lessp}
  585. as appropriate, or if string \i{a} is a proper prefix of string \i{b}
  586. (of shorter length and matching in all the characters of \i{a}).
  587. %Sandra is a little uncomfortable with the use of "equal" in the next two paragraphs.
  588. % -kmp 13-Jan-92
  589. The equality functions return a \param{generalized boolean}
  590. that is \term{true} if the strings are equal,
  591. or \term{false} otherwise.
  592. The inequality functions return a \param{mismatch-index}
  593. that is \term{true} if the strings are not equal,
  594. or \term{false} otherwise.
  595. When the \param{mismatch-index} is \term{true},
  596. it is an \term{integer} representing the first character position at which the
  597. two substrings differ, as an offset from the beginning of \param{string1}.
  598. %% This referred only to string= and string-equal, but was confusing and redundant.
  599. %% -kmp 25-Jul-91
  600. % %% 18.2.0 5
  601. % The equality functions return \term{false} if the substrings being compared are
  602. % of unequal length; that is, if
  603. %
  604. % \code
  605. % (not (= (- end1 start1) (- end2 start2)))
  606. % \endcode
  607. % is \term{true}, then the functions return \term{false}.
  608. The comparison has one of the following results:
  609. \beginlist
  610. \itemitem{\funref{string=}}
  611. \funref{string=} is \term{true} if the supplied substrings are of
  612. the same length and contain the \term{same} characters in corresponding
  613. positions; otherwise it is \term{false}.
  614. \itemitem{\funref{string/=}}
  615. \funref{string/=} is \term{true} if the supplied substrings are
  616. different; otherwise it is \term{false}.
  617. \itemitem{\funref{string-equal}}
  618. %% 18.2.0 8
  619. \funref{string-equal} is just like \funref{string=}
  620. except that differences in case are ignored;
  621. two characters are considered to be the same if \funref{char-equal} is \term{true} of them.
  622. \itemitem{\funref{string<}}
  623. \funref{string<} is \term{true} if substring1 is less than substring2;
  624. otherwise it is \term{false}.
  625. \itemitem{\funref{string>}}
  626. \funref{string>} is \term{true} if substring1 is greater than substring2;
  627. otherwise it is \term{false}.
  628. \itemitem{\funref{string-lessp}, \funref{string-greaterp}}
  629. %% 18.2.0 12
  630. \funref{string-lessp} and \funref{string-greaterp}
  631. are exactly like \funref{string<} and \funref{string>}, respectively,
  632. except that distinctions between uppercase and lowercase letters are ignored.
  633. It is as if \funref{char-lessp} were used instead of \funref{char<}
  634. for comparing characters.
  635. \itemitem{\funref{string<=}}
  636. \funref{string<=} is \term{true} if substring1 is less than or equal to substring2;
  637. otherwise it is \term{false}.
  638. \itemitem{\funref{string>=}}
  639. \funref{string>=} is \term{true} if substring1 is greater than or equal to substring2;
  640. otherwise it is \term{false}.
  641. \itemitem{\funref{string-not-greaterp}, \funref{string-not-lessp}}
  642. \funref{string-not-greaterp} and \funref{string-not-lessp}
  643. are exactly like \funref{string<=} and \funref{string>=}, respectively,
  644. except that distinctions between uppercase and lowercase letters are ignored.
  645. It is as if \funref{char-lessp} were used instead of \funref{char<}
  646. for comparing characters.
  647. \endlist
  648. %% Barrett: Implied by description of bounding.
  649. %All of these \term{functions} observe the \term{fill pointer}.
  650. \label Examples::
  651. %% 18.2.0 6
  652. \code
  653. (string= "foo" "foo") \EV \term{true}
  654. (string= "foo" "Foo") \EV \term{false}
  655. (string= "foo" "bar") \EV \term{false}
  656. (string= "together" "frog" :start1 1 :end1 3 :start2 2) \EV \term{true}
  657. (string-equal "foo" "Foo") \EV \term{true}
  658. (string= "abcd" "01234abcd9012" :start2 5 :end2 9) \EV \term{true}
  659. (string< "aaaa" "aaab") \EV 3
  660. (string>= "aaaaa" "aaaa") \EV 4
  661. (string-not-greaterp "Abcde" "abcdE") \EV 5
  662. (string-lessp "012AAAA789" "01aaab6" :start1 3 :end1 7
  663. :start2 2 :end2 6) \EV 6
  664. (string-not-equal "AAAA" "aaaA") \EV \term{false}
  665. \endcode
  666. \label Side Effects:\None.
  667. \label Affected By:\None.
  668. \label Exceptional Situations:\None.
  669. \label See Also::
  670. \funref{char=}
  671. \label Notes::
  672. %% 18.2.0 3
  673. \funref{equal} calls \funref{string=} if applied to two \term{strings}.
  674. \endcom
  675. %%% ========== STRINGP
  676. \begincom{stringp}\ftype{Function}
  677. \label Syntax::
  678. \DefunWithValues stringp {object} {generalized-boolean}
  679. \label Arguments and Values::
  680. \param{object}---an \term{object}.
  681. \param{generalized-boolean}---a \term{generalized boolean}.
  682. \label Description::
  683. %% 6.2.2 18
  684. \TypePredicate{object}{string}
  685. \label Examples::
  686. \code
  687. (stringp "aaaaaa") \EV \term{true}
  688. (stringp #\\a) \EV \term{false}
  689. \endcode
  690. \label Affected By:\None.
  691. \label Exceptional Situations:\None!
  692. \label See Also::
  693. \funref{typep},
  694. \typeref{string} (\term{type})
  695. \label Notes::
  696. \code
  697. (stringp \param{object}) \EQ (typep \param{object} 'string)
  698. \endcode
  699. \endcom
  700. %%% ========== MAKE-STRING
  701. \begincom{make-string}\ftype{Function}
  702. \label Syntax::
  703. \DefunWithValues make-string {size {\key} initial-element element-type} {string}
  704. \label Arguments and Values::
  705. \issue{ARGUMENTS-UNDERSPECIFIED:SPECIFY}
  706. \param{size}---a \term{valid array dimension}.
  707. \endissue{ARGUMENTS-UNDERSPECIFIED:SPECIFY}
  708. \issue{ARGUMENTS-UNDERSPECIFIED:SPECIFY}
  709. \param{initial-element}---a \term{character}.
  710. \endissue{ARGUMENTS-UNDERSPECIFIED:SPECIFY}
  711. \Default{\term{implementation-dependent}}
  712. \issue{CHARACTER-PROPOSAL:2-3-6}
  713. \param{element-type}---a \term{type specifier}.
  714. \Default{\typeref{character}}
  715. \endissue{CHARACTER-PROPOSAL:2-3-6}
  716. \param{string}---a \term{simple string}.
  717. \label Description::
  718. %% 18.3.0 3
  719. \funref{make-string} returns a \term{simple string} of length \param{size}
  720. whose elements have been initialized to \param{initial-element}.
  721. \issue{CHARACTER-PROPOSAL:2-3-6}
  722. The \param{element-type} names the \term{type} of the \term{elements} of the \term{string};
  723. a \term{string} is constructed of the most \term{specialized}
  724. \term{type} that can accommodate \term{elements} of the given \term{type}.
  725. \endissue{CHARACTER-PROPOSAL:2-3-6}
  726. \label Examples::
  727. \code
  728. (make-string 10 :initial-element #\\5) \EV "5555555555"
  729. (length (make-string 10)) \EV 10
  730. \endcode
  731. \label Affected By::
  732. The \term{implementation}.
  733. \label Exceptional Situations:\None.
  734. \label See Also:\None.
  735. %% Per X3J13. -kmp 05-Oct-93
  736. \label Notes:\None.
  737. \endcom
  738. %% 18.3.0 4
  739. %% was left out