dict-arrays.tex 83 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800
  1. % -*- Mode: TeX -*-
  2. % Arrays
  3. % Vectors
  4. % Bit Vectors
  5. % Strings
  6. %-------------------- Array types --------------------
  7. %% 2.5.0 1
  8. \begincom{array}\ftype{System Class}
  9. \label Class Precedence List::
  10. \typeref{array},
  11. \typeref{t}
  12. \label Description::
  13. An \term{array} contains \term{objects} arranged according to a
  14. Cartesian coordinate system.
  15. %% 2.5.1 4
  16. % {Symbolics rewrote the following}
  17. An \term{array} provides mappings from a set of
  18. \issue{ARRAY-DIMENSION-IMPLICATIONS:ALL-FIXNUM}
  19. \term{fixnums}
  20. \endissue{ARRAY-DIMENSION-IMPLICATIONS:ALL-FIXNUM}
  21. $\left\{i\sub{0},i\sub{1},\dots,i\sub{r-1}\right\}$ to corresponding \term{elements}
  22. of the \term{array},
  23. where $0 \le i\sub{j} < d\sub{j}$,
  24. $r$ is the rank of the array, and $d\sub{j}$ is the size of \term{dimension} $j$ of
  25. the array.
  26. When an \term{array} is created, the program requesting its creation may
  27. declare that all \term{elements} are of a particular \term{type},
  28. called the \term{expressed array element type}.
  29. The implementation is permitted to \term{upgrade} this type in order to
  30. produce the \term{actual array element type},
  31. which is the \term{element type} for the \term{array} is actually \term{specialized}.
  32. \Seefun{upgraded-array-element-type}.
  33. \label Compound Type Specifier Kind::
  34. Specializing.
  35. \label Compound Type Specifier Syntax::
  36. \Deftype{array}{\ttbrac{\curly{element-type | \misc{*}} \brac{dimension-spec}}}
  37. \auxbnf{dimension-spec}{rank | \misc{*} | \paren{\star{\curly{dimension | \misc{*}}}}}
  38. \label Compound Type Specifier Arguments::
  39. \param{dimension}---a \term{valid array dimension}.
  40. \param{element-type}---a \term{type specifier}.
  41. \issue{ARRAY-DIMENSION-IMPLICATIONS:ALL-FIXNUM}
  42. \param{rank}---a non-negative \term{fixnum}.
  43. \endissue{ARRAY-DIMENSION-IMPLICATIONS:ALL-FIXNUM}
  44. \label Compound Type Specifier Description::
  45. %% 4.5.0 6
  46. %% 4.5.0 7
  47. This denotes the set of \term{arrays} whose
  48. \term{element type}, \term{rank}, and \term{dimensions}
  49. match any given
  50. \param{element-type}, \param{rank}, and \param{dimensions}.
  51. Specifically:
  52. If \param{element-type} is the \term{symbol} \misc{*},
  53. \term{arrays} are not excluded on the basis of their \term{element type}.
  54. Otherwise, only those \param{arrays} are included whose \term{actual array element type}
  55. \issue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  56. is the result of \term{upgrading} \param{element-type};
  57. \seesection\ArrayUpgrading.
  58. %The following will be left out:
  59. %\param{element-type}
  60. %% The following seems redundant. -kmp 20-Oct-91
  61. % {\tt (array \param{type-specifier})}
  62. % refers only to those \term{arrays}
  63. % that can result from giving \param{type-specifier} as the
  64. % \kwd{element-type} argument to \funref{make-array}.
  65. \endissue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  66. If the \param{dimension-spec} is a \param{rank},
  67. the set includes only those \param{arrays} having that \term{rank}.
  68. If the \param{dimension-spec} is a \term{list} of \param{dimensions},
  69. the set includes only those \param{arrays} having a \term{rank}
  70. given by the \term{length} of the \param{dimensions},
  71. and having the indicated \param{dimensions};
  72. in this case, \misc{*} matches any value for the corresponding \term{dimension}.
  73. If the \param{dimension-spec} is the \term{symbol} \misc{*},
  74. the set is not restricted on the basis of \term{rank} or \term{dimension}.
  75. \issue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  76. %The following will be left out:
  77. %
  78. %For declaration purposes, this \term{type} encompasses those
  79. %\term{arrays}
  80. %that can result by supplying \param{element-type} as the element type
  81. %to \thefunction{make-array}; this might be different
  82. %from what the \term{type} means for discrimination purposes.
  83. %For example:
  84. %
  85. %\code
  86. % (array integer 3) ;Three-dimensional arrays of integers
  87. % (array integer (* * *)) ;Three-dimensional arrays of integers
  88. % (array * (4 5 6)) ;4-by-5-by-6 arrays
  89. % (array character (3 *)) ;Two-dimensional arrays of characters that have
  90. % ;three rows
  91. % (array short-float \empty) ;Zero-rank arrays of short-floats
  92. %\endcode
  93. \endissue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  94. \label See Also::
  95. \varref{*print-array*},
  96. \funref{aref},
  97. \funref{make-array},
  98. \typeref{vector},
  99. {\secref\SharpsignA},
  100. {\secref\PrintingOtherArrays}
  101. \label Notes::
  102. Note that the type {\tt (array t)}
  103. is a proper \term{subtype} of the type {\tt (array *)}.
  104. The reason is that the type {\tt (array t)} is the set of \term{arrays}
  105. that can
  106. hold any \term{object} (the \term{elements} are \oftype{t}, which includes
  107. all \term{objects}).
  108. On the other hand, the type {\tt (array *)}
  109. is the set of all \term{arrays} whatsoever, including for example
  110. \term{arrays} that can hold only \term{characters}.
  111. %% possible issue here that: ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS says that
  112. %%this example only works in implementations that have specialized arrays for
  113. %%elements of type character, not required in CL. But char committee may
  114. %%require them.
  115. The type {\tt (array character)}
  116. is not a \term{subtype} of the type {\tt (array t)};
  117. the two sets
  118. are \term{disjoint} because the type {\tt (array character)} is not the
  119. set of all \term{arrays} that can hold
  120. \term{characters}, but rather the set of
  121. \term{arrays}
  122. that are specialized to hold precisely \term{characters} and no
  123. other \term{objects}.
  124. %The following expression cannot be used to determine if
  125. %array \f{foo} can hold a \term{character}:
  126. %
  127. %\code
  128. % (typep foo '(array character))
  129. %\endcode
  130. %The following expression can be used to determine if
  131. %array \f{foo} can hold a \term{character}:
  132. %
  133. %\code
  134. % (subtypep 'character (array-element-type foo))
  135. %\endcode
  136. \endcom%{array}\ftype{System Class}
  137. %% 2.5.0 9
  138. \begincom{simple-array}\ftype{Type}
  139. \label Supertypes::
  140. \typeref{simple-array},
  141. %% 2.15.0 20
  142. \typeref{array},
  143. \typeref{t}
  144. \label Description::
  145. %Per Symbolics comments, this is reworded to clarify that this only defines
  146. %things that might be simple, not what must be:
  147. %An \term{array}
  148. %that is not displaced to another \term{array}, has no \term{fill pointer},
  149. %and is not to have its size adjusted dynamically after
  150. %creation is a \term{simple array}.
  151. The \term{type} of an \term{array} that is not displaced
  152. to another \term{array}, has no \term{fill pointer}, and is
  153. % \reviewer{Barrett: Reexamine in light of ADJUST-ARRAY-NOT-ADJUSTABLE--specifically,
  154. % all arrays are now valid to adjust-array--they just don't all get changed by side-effect.}
  155. not
  156. \term{expressly adjustable} is a \subtypeof{simple-array}.
  157. The concept of a \term{simple array}
  158. exists to allow the implementation to use a specialized representation
  159. and to allow the user to declare that certain values will always be
  160. \term{simple arrays}.
  161. %% 2.15.0 21
  162. The \term{types} \typeref{simple-vector},
  163. \typeref{simple-string},
  164. and \typeref{simple-bit-vector}
  165. are \term{disjoint} \subtypesof{simple-array},
  166. for they respectively mean \f{(simple-array t (*))},
  167. the union of all \f{(simple-array \i{c} (*))}
  168. for any \i{c} being a \subtypeof{character},
  169. and \f{(simple-array bit (*))}.
  170. \label Compound Type Specifier Kind::
  171. Specializing.
  172. %% 4.5.0 8
  173. \label Compound Type Specifier Syntax::
  174. \Deftype{simple-array}{\ttbrac{\curly{element-type | \misc{*}} \brac{dimension-spec}}}
  175. \auxbnf{dimension-spec}{rank | \misc{*} | \paren{\star{\curly{dimension | \misc{*}}}}}
  176. \label Compound Type Specifier Arguments::
  177. \param{dimension}---a \term{valid array dimension}.
  178. \param{element-type}---a \term{type specifier}.
  179. \issue{ARRAY-DIMENSION-IMPLICATIONS:ALL-FIXNUM}
  180. \param{rank}---a non-negative \term{fixnum}.
  181. \endissue{ARRAY-DIMENSION-IMPLICATIONS:ALL-FIXNUM}
  182. \label Compound Type Specifier Description::
  183. This \term{compound type specifier} is treated exactly as the corresponding
  184. \term{compound type specifier} for \term{type} \typeref{array} would be treated,
  185. except that the set is further constrained to include only \term{simple arrays}.
  186. % This denotes the set of \term{simple arrays} whose elements are all of \term{type}
  187. % \issue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  188. % {\penalty-50}\f{(upgraded-array-element-type \param{element-type})}
  189. % %The following will be left out:
  190. % %\param{element-type}
  191. % \endissue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  192. % and whose dimensions are \param{dimensions}.
  193. % \param{Element-type} must be a valid \term{type specifier} or \misc{*}.
  194. % \issue{ARRAY-DIMENSION-LIMIT-IMPLICATIONS:ALL-FIXNUM}
  195. % \param{Dimensions} must be a non-negative \term{fixnum},
  196. % \endissue{ARRAY-DIMENSION-LIMIT-IMPLICATIONS:ALL-FIXNUM}
  197. % which is the number
  198. % of dimensions, or a \term{list} of \term{valid array dimensions}
  199. % representing the length of each dimension (any dimension
  200. % can be \misc{*} instead), or it can be \misc{*}.
  201. \label Notes::
  202. It is \term{implementation-dependent}
  203. whether \term{displaced arrays},
  204. \term{vectors} with \term{fill pointers},
  205. or arrays that are \term{actually adjustable}
  206. are \term{simple arrays}.
  207. \issue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  208. {\tt (simple-array *)} refers to all \term{simple arrays}
  209. regardless of element type, {\tt (simple-array \param{type-specifier})}
  210. refers only to those \term{simple arrays}
  211. that can result from giving \param{type-specifier} as the
  212. \kwd{element-type} argument to \funref{make-array}.
  213. \endissue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  214. \endcom%{simple-array}\ftype{Type}
  215. %% 2.5.1 1
  216. \begincom{vector}\ftype{System Class}
  217. \label Class Precedence List::
  218. \typeref{vector},
  219. \typeref{array},
  220. \typeref{sequence},
  221. \typeref{t}
  222. \label Description::
  223. Any one-dimensional \term{array} is a \term{vector}.
  224. %% 2.15.0 19
  225. \Thetype{vector} is a \subtypeof{array};
  226. for all \term{types} \f{x}, {\tt (vector x)} is the same as {\tt (array x (*))}.
  227. %% 2.15.0 18
  228. The \term{type} {\tt (vector t)}, \thetype{string}, and \thetype{bit-vector}
  229. are \term{disjoint} \subtypesof{vector}.
  230. \label Compound Type Specifier Kind::
  231. Specializing.
  232. \label Compound Type Specifier Syntax::
  233. %% 4.5.0 9
  234. \Deftype{vector}{\ttbrac{\curly{element-type | \misc{*}} \brac{\curly{size | \misc{*}}}}}
  235. \label Compound Type Specifier Arguments::
  236. \issue{ARRAY-DIMENSION-IMPLICATIONS:ALL-FIXNUM}
  237. \param{size}---a non-negative \term{fixnum}.
  238. \endissue{ARRAY-DIMENSION-IMPLICATIONS:ALL-FIXNUM}
  239. \param{element-type}---a \term{type specifier}.
  240. \label Compound Type Specifier Description::
  241. This denotes the set of specialized \term{vectors}
  242. whose \term{element type} and \param{dimension} match the specified values.
  243. Specifically:
  244. If \param{element-type} is the \term{symbol} \misc{*},
  245. \term{vectors} are not excluded on the basis of their \term{element type}.
  246. Otherwise, only those \param{vectors} are included whose \term{actual array element type}
  247. \issue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  248. is the result of \term{upgrading} \param{element-type};
  249. \seesection\ArrayUpgrading.
  250. \endissue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  251. If a \param{size} is specified,
  252. the set includes only those \param{vectors} whose only \term{dimension}
  253. is \param{size}.
  254. If the \term{symbol} \misc{*} is specified instead of a \param{size},
  255. the set is not restricted on the basis of \term{dimension}.
  256. \label See Also::
  257. {\secref\RequiredSpecializedArrays},
  258. {\secref\SharpsignLeftParen},
  259. {\secref\PrintingOtherVectors},
  260. {\secref\SharpsignA}
  261. \label Notes::
  262. The \term{type} \f{(vector \param{e} \param{s})}
  263. is equivalent to the \term{type} \f{(array \param{e} (\param{s}))}.
  264. The type \f{(vector bit)} has the name \typeref{bit-vector}.
  265. The union of all \term{types} \f{(vector $C$)},
  266. where $C$ is any \term{subtype} of \typeref{character},
  267. has the name \typeref{string}.
  268. %Every implementation of \clisp\ must provide distinct representations for
  269. %these as distinct specialized \term{types}.
  270. \issue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  271. {\tt (vector *)} refers to all \term{vectors}
  272. regardless of element type, {\tt (vector \param{type-specifier})}
  273. refers only to those \term{vectors}
  274. that can result from giving \param{type-specifier} as the
  275. \kwd{element-type} argument to \funref{make-array}.
  276. \endissue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  277. \endcom%{vector}\ftype{System Class}
  278. \begincom{simple-vector}\ftype{Type}
  279. \label Supertypes::
  280. \typeref{simple-vector},
  281. \typeref{vector},
  282. \typeref{simple-array},
  283. \typeref{array},
  284. \typeref{sequence},
  285. \typeref{t}
  286. \label Description::
  287. % This sentence replaced per Symbolics comments:
  288. % A \term{vector} that is not displaced to another \term{array}, has no
  289. % \term{fill pointer}, is able to hold elements of any \term{type},
  290. % and is not to have its size adjusted dynamically after creation is a
  291. % \term{simple vector}.
  292. The \term{type} of a \term{vector} that is not displaced to another
  293. \term{array}, has no \term{fill pointer}, is not
  294. %to have its size adjusted dynamically after creation,
  295. \term{expressly adjustable}
  296. and is able to hold
  297. elements of any \term{type} is a \subtypeof{simple-vector}.
  298. %% 2.15.0 22
  299. \Thetype{simple-vector} is a \subtypeof{vector},
  300. and is a \term{subtype} of \term{type} \f{(vector t)}.
  301. \label Compound Type Specifier Kind::
  302. Specializing.
  303. \label Compound Type Specifier Syntax::
  304. \Deftype{simple-vector}{\ttbrac{size}}
  305. \label Compound Type Specifier Arguments::
  306. \issue{ARRAY-DIMENSION-IMPLICATIONS:ALL-FIXNUM}
  307. \param{size}---a non-negative \term{fixnum},
  308. or the \term{symbol} \misc{*}.
  309. \Default{the \term{symbol} \misc{*}}
  310. \endissue{ARRAY-DIMENSION-IMPLICATIONS:ALL-FIXNUM}
  311. \label Compound Type Specifier Description::
  312. %% 4.5.0 10
  313. %\itemitem{\tt (simple-vector \param{size})}
  314. This is the same as {\tt (simple-array t (\param{size}))}.
  315. %This is the same as {\tt (and (vector t \param{size}) simple-array)}.
  316. % This is the same
  317. % as the type \f{(vector t \param{size})}
  318. % except that \typeref{simple-vector} also specifies
  319. % that its members are \term{simple arrays}.
  320. \endcom%{simple-vector}\ftype{Type}
  321. \begincom{bit-vector}\ftype{System Class}
  322. \label Class Precedence List::
  323. \typeref{bit-vector},
  324. \typeref{vector},
  325. \typeref{array},
  326. \typeref{sequence},
  327. \typeref{t}
  328. \label Description::
  329. A \term{bit vector} is a \term{vector} the \term{element type} of which is \term{bit}.
  330. %% 2.15.0 17
  331. \Thetype{bit-vector} is a \subtypeof{vector},
  332. for \typeref{bit-vector} means \f{(vector bit)}.
  333. \label Compound Type Specifier Kind::
  334. Abbreviating.
  335. \label Compound Type Specifier Syntax::
  336. %% 4.6.0 12
  337. \Deftype{bit-vector}{\ttbrac{size}}
  338. \label Compound Type Specifier Arguments::
  339. \issue{ARRAY-DIMENSION-IMPLICATIONS:ALL-FIXNUM}
  340. \param{size}---a non-negative \term{fixnum},
  341. or the \term{symbol} \misc{*}.
  342. \endissue{ARRAY-DIMENSION-IMPLICATIONS:ALL-FIXNUM}
  343. \label Compound Type Specifier Description::
  344. This denotes the same \term{type} as the \term{type} {\tt (array bit (\param{size}))};
  345. that is, the set of \term{bit vectors} of size \param{size}.
  346. \label See Also::
  347. {\secref\SharpsignStar},
  348. {\secref\PrintingBitVectors},
  349. {\secref\RequiredSpecializedArrays}
  350. \endcom%{bit-vector}\ftype{System Class}
  351. \begincom{simple-bit-vector}\ftype{Type}
  352. \label Supertypes::
  353. \typeref{simple-bit-vector},
  354. %% 2.15.0 25
  355. \typeref{bit-vector},
  356. \typeref{vector},
  357. \typeref{simple-array},
  358. \typeref{array},
  359. \typeref{sequence},
  360. \typeref{t}
  361. \label Description::
  362. % Reworded per Symbolics comments:
  363. % A \term{bit vector} that is not displaced to another
  364. % \term{array}, has no \term{fill pointer}, and is not to have its
  365. % size adjusted dynamically after creation is a \term{simple bit vector}.
  366. The \term{type} of a \term{bit vector} that is not displaced
  367. to another \term{array}, has no \term{fill pointer}, and is
  368. not
  369. %to have its size adjusted dynamically after creation
  370. \term{expressly adjustable}
  371. is a
  372. \subtypeof{simple-bit-vector}.
  373. \label Compound Type Specifier Kind::
  374. Abbreviating.
  375. \label Compound Type Specifier Syntax::
  376. %% 4.6.0 13
  377. \Deftype{simple-bit-vector}{\ttbrac{size}}
  378. \label Compound Type Specifier Arguments::
  379. \issue{ARRAY-DIMENSION-IMPLICATIONS:ALL-FIXNUM}
  380. \param{size}---a non-negative \term{fixnum},
  381. or the \term{symbol} \misc{*}.
  382. \Default{the \term{symbol} \misc{*}}
  383. \endissue{ARRAY-DIMENSION-IMPLICATIONS:ALL-FIXNUM}
  384. \label Compound Type Specifier Description::
  385. This denotes the same type as the \term{type}
  386. \f{(simple-array bit (\param{size}))};
  387. that is, the set of \term{simple bit vectors} of size \param{size}.
  388. \endcom%{simple-bit-vector}\ftype{Type}
  389. %-------------------- Arrays --------------------
  390. %%% ========== MAKE-ARRAY
  391. \begincom{make-array}\ftype{Function}
  392. \label Syntax::
  393. \DefunWithValuesNewline make-array
  394. {dimensions {\key} \vtop{\hbox{element-type}
  395. \hbox{initial-element}
  396. \hbox{initial-contents}
  397. \hbox{adjustable}
  398. \hbox{fill-pointer}
  399. \hbox{displaced-to}
  400. \hbox{displaced-index-offset}}}
  401. {new-array}
  402. \label Arguments and Values::
  403. %% 17.1.0 3
  404. \param{dimensions}---a \term{designator} for a \term{list} of \term{valid array dimensions}.
  405. %% 17.1.0 6
  406. \param{element-type}---a \term{type specifier}.
  407. \Default{\typeref{t}}
  408. \param{initial-element}---an \term{object}.
  409. \param{initial-contents}---an \term{object}.
  410. %Per Barmar, remove (or sequence vector) because 0-dimension case doesn't care. -kmp 24-Jul-91
  411. \param{adjustable}---a \term{generalized boolean}.
  412. \Default{\nil}
  413. %!!! Is there a designator for this?
  414. \param{fill-pointer}---a \term{valid fill pointer} for the \term{array} to be created,
  415. or \t\ or \nil.
  416. \Default{\nil}
  417. %% 17.1.0 11
  418. \param{displaced-to}---an \term{array} or \nil.
  419. \Default{\nil}
  420. This option must not be supplied if either \param{initial-element}
  421. or \param{initial-contents} is supplied.
  422. %% 17.1.0 12
  423. \param{displaced-index-offset}---a \term{valid array row-major index}
  424. for \param{displaced-to}. \Default{\f{0}}
  425. This option must not be supplied unless a \term{non-nil} \param{displaced-to} is supplied.
  426. \param{new-array}---an \term{array}.
  427. \label Description::
  428. Creates and returns an \term{array} constructed of the most \term{specialized}
  429. \term{type} that can accommodate elements of \term{type} given by \param{element-type}.
  430. If \param{dimensions} is \nil\ then a zero-dimensional \term{array} is created.
  431. \param{Dimensions} represents the dimensionality of the new \term{array}.
  432. \param{element-type} indicates the \term{type} of the elements intended to be stored
  433. in the \param{new-array}. The \param{new-array} can actually store any \term{objects}
  434. of the \term{type} which results from \term{upgrading} \param{element-type};
  435. \seesection\ArrayUpgrading.
  436. %% 17.1.0 7
  437. If \param{initial-element} is supplied,
  438. it is used to initialize each \term{element} of \param{new-array}.
  439. If \param{initial-element} is supplied,
  440. it must be of the \term{type} given by \param{element-type}.
  441. \param{initial-element} cannot be supplied if either the \kwd{initial-contents} option
  442. is supplied or \param{displaced-to} is \term{non-nil}.
  443. If \param{initial-element} is not supplied,
  444. \issue{UNINITIALIZED-ELEMENTS:CONSEQUENCES-UNDEFINED}
  445. %% This issue finally did pass at the March-93 meeting. -kmp 5-May-93
  446. % the initial values of the \term{array} \term{elements} are
  447. % %%Rewritten to conform to the fact that issue UNINITIALIZED-ELEMENTS failed
  448. % %%to clarify this in the other direction because consensus was that this was well-defined
  449. % %%already. -kmp 15-Jan-92
  450. % %undefined
  451. % \term{implementation-dependent}
  452. the consequences of later reading an uninitialized \term{element} of \param{new-array}
  453. are undefined
  454. \endissue{UNINITIALIZED-ELEMENTS:CONSEQUENCES-UNDEFINED}
  455. unless either \param{initial-contents} is supplied
  456. or \param{displaced-to} is \term{non-nil}.
  457. %% 17.1.0 8
  458. \param{initial-contents} is used to initialize the contents of \term{array}.
  459. For example:
  460. \code
  461. (make-array '(4 2 3) :initial-contents
  462. '(((a b c) (1 2 3))
  463. ((d e f) (3 1 2))
  464. ((g h i) (2 3 1))
  465. ((j k l) (0 0 0))))
  466. \endcode
  467. %!!! Is ADJUST-ARRAY-NOT-ADJUSTABLE:IMPLICIT-COPY fully merged?
  468. \param{initial-contents} is composed of a nested structure of \term{sequences}.
  469. The numbers of levels in the structure must equal the rank of \term{array}.
  470. Each leaf of the nested structure must be of the \term{type} given by \param{element-type}.
  471. If \term{array} is zero-dimensional, then \param{initial-contents} specifies the single
  472. \term{element}. Otherwise, \param{initial-contents} must be a \term{sequence}
  473. whose length is equal to the first dimension; each element must be a nested
  474. structure for an \term{array} whose dimensions are the remaining dimensions,
  475. and so on.
  476. \param{Initial-contents} cannot be supplied if either
  477. \param{initial-element} is supplied
  478. or \param{displaced-to} is \term{non-nil}.
  479. If \param{initial-contents} is not supplied,
  480. \issue{UNINITIALIZED-ELEMENTS:CONSEQUENCES-UNDEFINED}
  481. %% This issue finally did pass at the March-93 meeting. -kmp 5-May-93
  482. % the initial values of the \term{array} \term{elements} are
  483. % %%Rewritten to conform to the fact that issue UNINITIALIZED-ELEMENTS failed
  484. % %%to clarify this in the other direction because consensus was that this was well-defined
  485. % %%already. -kmp 15-Jan-92
  486. % %undefined
  487. % \term{implementation-dependent}
  488. the consequences of later reading an uninitialized \term{element} of \param{new-array}
  489. are undefined
  490. \endissue{UNINITIALIZED-ELEMENTS:CONSEQUENCES-UNDEFINED}
  491. unless either \param{initial-element} is supplied
  492. or \param{displaced-to} is \term{non-nil}.
  493. %% KMP's rewrite:
  494. % %% 17.1.0 9
  495. % If \param{adjustable} is \term{non-nil},
  496. % the array is both \term{expressly adjustable}
  497. % and \term{actually adjustable};
  498. % otherwise, the array is not \term{expressly adjustable}
  499. % and it is \term{implementation-dependent} whether
  500. % the array is \term{actually adjustable}.
  501. %% To which Barrett suggested:
  502. % If \param{adjustable} is \term{non-nil},
  503. % the array is \term{expressly adjustable};
  504. % otherwise, it is \term{implementation-dependent} whether
  505. % the array is \term{actually adjustable}.
  506. %% We have compromised on:
  507. %% 17.1.0 9
  508. If \param{adjustable} is \term{non-nil},
  509. the array is \term{expressly adjustable}
  510. (and so \term{actually adjustable});
  511. otherwise, the array is not \term{expressly adjustable}
  512. (and it is \term{implementation-dependent} whether
  513. the array is \term{actually adjustable}).
  514. % ...
  515. % it is possible to alter the \term{array}'s size dynamically after it is created.
  516. %\issue{ADJUST-ARRAY-NOT-ADJUSTABLE:DONKEY}
  517. %and \funref{adjustable-array-p} will be true.
  518. %If \param{adjustable} is not supplied or \nil,
  519. %\term{array} is not required to be
  520. %adjustable, but a non-adjustable \term{array} is not guaranteed.
  521. %\endissue{ADJUST-ARRAY-NOT-ADJUSTABLE:DONKEY}
  522. %% 17.1.0 10
  523. If \param{fill-pointer} is \term{non-nil},
  524. the \term{array} must be one-dimensional;
  525. that is, the \term{array} must be a \term{vector}.
  526. If \param{fill-pointer} is \t,
  527. the length of the \term{vector} is used to initialize the \term{fill pointer}.
  528. If \param{fill-pointer} is an \term{integer},
  529. it becomes the initial \term{fill pointer} for the \term{vector}.
  530. If \param{displaced-to} is \term{non-nil},
  531. \funref{make-array} will create a \term{displaced array}
  532. and \param{displaced-to} is the \term{target} of that \term{displaced array}.
  533. In that case, the consequences are undefined if the \term{actual array element type} of
  534. \param{displaced-to} is not \term{type equivalent} to the \term{actual array element type}
  535. of the \term{array} being created.
  536. If \param{displaced-to} is \nil, the \term{array} is not a \term{displaced array}.
  537. %!!! should "index offset" or "displaced index offset" be a formal term?
  538. The \param{displaced-index-offset} is made to be the index offset of the \term{array}.
  539. %% 17.1.0 13
  540. When an array A is given as
  541. \thekeyarg{displaced-to} to \funref{make-array}
  542. when creating array B,
  543. then array B is said to be displaced to array A. The
  544. total number of elements in an \term{array},
  545. called the total size of the \term{array},
  546. is calculated as the product of all the dimensions.
  547. It is required that the total size of A be no smaller than the sum
  548. of the total size of B plus the offset \f{n} supplied by
  549. the \param{displaced-index-offset}.
  550. The effect of displacing is that array B does not have any
  551. elements of its own, but instead maps \term{accesses} to itself into
  552. \term{accesses} to array A. The mapping treats both \term{arrays} as if they
  553. were one-dimensional by taking the elements in row-major order,
  554. and then maps an \term{access} to element \f{k} of array B to an \term{access} to element
  555. \f{k}+\f{n} of array A.
  556. %% 17.1.0 14
  557. If \funref{make-array} is called with \param{adjustable}, \param{fill-pointer},
  558. and \param{displaced-to} each \nil,
  559. then the result is a \term{simple array}.
  560. \issue{ADJUST-ARRAY-NOT-ADJUSTABLE:IMPLICIT-COPY}
  561. If \funref{make-array} is called with one or more of \param{adjustable},
  562. \param{fill-pointer}, or \param{displaced-to} being \term{true}, whether the
  563. resulting \term{array} is a \term{simple array} is \term{implementation-dependent}.
  564. \endissue{ADJUST-ARRAY-NOT-ADJUSTABLE:IMPLICIT-COPY}
  565. %% 17.1.0 13
  566. When an array A is given as \thekeyarg{displaced-to} to
  567. \funref{make-array} when creating array B, then array B is said to
  568. be displaced to array A. The total number of elements in an \term{array},
  569. called the total size of the \term{array}, is calculated as the product
  570. of all the dimensions.
  571. The consequences are unspecified if
  572. the total size of A is smaller than the sum
  573. of the total size of B plus the offset \f{n} supplied by
  574. the \param{displaced-index-offset}.
  575. The effect of displacing is that array B does not have any
  576. elements of its own, but instead maps \term{accesses} to itself into
  577. \term{accesses} to array A. The mapping treats both \term{arrays} as if they
  578. were one-dimensional by taking the elements in row-major order,
  579. and then maps an \term{access} to element \f{k} of array B to an \term{access}
  580. to \term{element} \f{k}+\f{n} of array A.
  581. %% Redundant with previous paragraph.
  582. % When \kwd{displaced-to} is supplied to \funref{make-array},
  583. % the \param{displaced-index-offset} is made to be the
  584. % index offset of the \term{array}.
  585. %% Redundant with Arguments and Values above.
  586. % If the \param{displaced-index-offset} is not supplied,
  587. % the index offset is zero.
  588. \label Examples::
  589. %% 17.1.0 15
  590. \code
  591. (make-array 5) ;; Creates a one-dimensional array of five elements.
  592. (make-array '(3 4) :element-type '(mod 16)) ;; Creates a
  593. ;;two-dimensional array, 3 by 4, with four-bit elements.
  594. (make-array 5 :element-type 'single-float) ;; Creates an array of single-floats.
  595. \endcode
  596. \code
  597. (make-array nil :initial-element nil) \EV #0ANIL
  598. (make-array 4 :initial-element nil) \EV #(NIL NIL NIL NIL)
  599. (make-array '(2 4)
  600. :element-type '(unsigned-byte 2)
  601. :initial-contents '((0 1 2 3) (3 2 1 0)))
  602. \EV #2A((0 1 2 3) (3 2 1 0))
  603. (make-array 6
  604. :element-type 'character
  605. :initial-element #\\a
  606. :fill-pointer 3) \EV "aaa"
  607. \endcode
  608. The following is an example of making a \term{displaced array}.
  609. \code
  610. (setq a (make-array '(4 3)))
  611. \EV #<ARRAY 4x3 simple 32546632>
  612. (dotimes (i 4)
  613. (dotimes (j 3)
  614. (setf (aref a i j) (list i 'x j '= (* i j)))))
  615. \EV NIL
  616. (setq b (make-array 8 :displaced-to a
  617. :displaced-index-offset 2))
  618. \EV #<ARRAY 8 indirect 32550757>
  619. (dotimes (i 8)
  620. (print (list i (aref b i))))
  621. \OUT (0 (0 X 2 = 0))
  622. \OUT (1 (1 X 0 = 0))
  623. \OUT (2 (1 X 1 = 1))
  624. \OUT (3 (1 X 2 = 2))
  625. \OUT (4 (2 X 0 = 0))
  626. \OUT (5 (2 X 1 = 2))
  627. \OUT (6 (2 X 2 = 4))
  628. \OUT (7 (3 X 0 = 0))
  629. \EV NIL
  630. \endcode
  631. The last example depends on the fact that \term{arrays} are, in effect,
  632. stored in row-major order.
  633. \code
  634. (setq a1 (make-array 50))
  635. \EV #<ARRAY 50 simple 32562043>
  636. (setq b1 (make-array 20 :displaced-to a1 :displaced-index-offset 10))
  637. \EV #<ARRAY 20 indirect 32563346>
  638. (length b1) \EV 20
  639. (setq a2 (make-array 50 :fill-pointer 10))
  640. \EV #<ARRAY 50 fill-pointer 10 46100216>
  641. (setq b2 (make-array 20 :displaced-to a2 :displaced-index-offset 10))
  642. \EV #<ARRAY 20 indirect 46104010>
  643. (length a2) \EV 10
  644. (length b2) \EV 20
  645. (setq a3 (make-array 50 :fill-pointer 10))
  646. \EV #<ARRAY 50 fill-pointer 10 46105663>
  647. (setq b3 (make-array 20 :displaced-to a3 :displaced-index-offset 10
  648. :fill-pointer 5))
  649. \EV #<ARRAY 20 indirect, fill-pointer 5 46107432>
  650. (length a3) \EV 10
  651. (length b3) \EV 5
  652. \endcode
  653. \label Affected By:\None.
  654. \label Exceptional Situations:\None.
  655. \label See Also::
  656. \funref{adjustable-array-p},
  657. \funref{aref},
  658. \funref{arrayp},
  659. \funref{array-element-type},
  660. \conref{array-rank-limit},
  661. \conref{array-dimension-limit},
  662. \funref{fill-pointer},
  663. \funref{upgraded-array-element-type}
  664. \label Notes::
  665. \issue{ADJUST-ARRAY-NOT-ADJUSTABLE:IMPLICIT-COPY}
  666. There is no specified way to create an \term{array}
  667. for which \funref{adjustable-array-p} definitely
  668. returns \term{false}.
  669. There is no specified way to create an \term{array}
  670. that is not a \term{simple array}.
  671. \endissue{ADJUST-ARRAY-NOT-ADJUSTABLE:IMPLICIT-COPY}
  672. \endcom
  673. %%% ========== ADJUST-ARRAY
  674. \begincom{adjust-array}\ftype{Function}
  675. %!!! Barmar's review comments of this were made on the basis of document that
  676. % did not include various cleanups. This should be re-reviewed carefully later.
  677. % -kmp 17-Dec-90
  678. \label Syntax::
  679. \DefunWithValuesNewline adjust-array
  680. {array new-dimensions {\key} \vtop{\hbox{element-type}
  681. \hbox{initial-element}
  682. \hbox{initial-contents}
  683. \hbox{fill-pointer}
  684. \hbox{displaced-to}
  685. \hbox{displaced-index-offset}}}
  686. {adjusted-array}
  687. \label Arguments and Values::
  688. \param{array}---an \term{array}.
  689. \param{new-dimensions}---a \term{valid array dimension}
  690. or a \term{list} of \term{valid array dimensions}.
  691. %% 17.6.0 6
  692. \param{element-type}---a \term{type specifier}.
  693. %!!! Not sure how to express the default. Mail sent to Quinquevirate asking for thoughts.
  694. %% 17.6.0 7
  695. \param{initial-element}---an \term{object}.
  696. \param{Initial-element} must not be supplied if either
  697. \param{initial-contents} or \param{displaced-to} is supplied.
  698. %!!! How to express this default??
  699. %!!! "array contents designator" ? -kmp 14-May-91
  700. \param{initial-contents}---an \term{object}.
  701. If \term{array} has rank greater than zero, then \param{initial-contents}
  702. is composed of nested \term{sequences}, the depth of which must equal
  703. the rank of \param{array}. Otherwise, \term{array} is zero-dimensional and
  704. \param{initial-contents} supplies the single element.
  705. \param{initial-contents} must not be supplied if either
  706. \param{initial-element} or \param{displaced-to} is given.
  707. %% 17.6.0 8
  708. \param{fill-pointer}---a \term{valid fill pointer} for the
  709. \term{array} to be created, or \t, or \nil.
  710. \Default{\nil}
  711. \param{displaced-to}---an \term{array} or \nil.
  712. \param{initial-elements} and \param{initial-contents} must not be supplied
  713. if \param{displaced-to} is supplied.
  714. %!!! Default?
  715. \issue{ARRAY-DIMENSION-LIMIT-IMPLICATIONS:ALL-FIXNUM}
  716. \param{displaced-index-offset}---an \objectoftype{(fixnum 0 \i{n})}
  717. where \i{n} is {\tt (array-total-size \param{displaced-to})}.
  718. \param{displaced-index-offset} may be supplied only if \param{displaced-to} is supplied.
  719. %!!! Default?
  720. \endissue{ARRAY-DIMENSION-LIMIT-IMPLICATIONS:ALL-FIXNUM}
  721. \param{adjusted-array}---an \term{array}.
  722. \label Description::
  723. %% 17.6.0 3
  724. \funref{adjust-array} changes the dimensions or elements of \param{array}.
  725. The result is an \term{array} of the same \term{type} and rank as \param{array},
  726. %% 17.6.0 4
  727. %% 17.6.0 9
  728. that is either the modified \param{array},
  729. or a newly created \term{array} to which
  730. \param{array} can be displaced, and that has
  731. the given \param{new-dimensions}.
  732. %% Sandra points out that this is implied by the definition of "valid array dimension".
  733. % The total number of elements that \param{array}
  734. % can contain (as given by the
  735. % product of all \param{new-dimensions}) must be less than
  736. % \conref{array-total-size-limit}.
  737. \param{New-dimensions} specify the size of each \term{dimension} of \param{array}.
  738. \param{Element-type} specifies the \term{type} of the \term{elements}
  739. of the resulting \term{array}. If \param{element-type} is supplied,
  740. % % the consequences are unspecified if it is not a \term{type}
  741. % % %What does "compatible" mean here?? -kmp 29-Apr-91
  742. % % %Sandra's curious, too. -kmp 14-Feb-92
  743. % % that is compatible with {\tt (array-element-type \param{array})}.
  744. % %% Sandra's suggested rewrite:
  745. % the consequences are unspecified if
  746. % \f{(upgraded-array-element-type \param{element-type})}
  747. % is not the same as {\tt (array-element-type \param{array})}.
  748. %% KMP's rewrite
  749. the consequences are unspecified if
  750. the \term{upgraded array element type} of \param{element-type}
  751. is not the same as the \term{actual array element type} of \param{array}.
  752. %% Sandra thinks this is redundant.
  753. % If the resulting \term{array} is a displaced \term{array},
  754. % the consequences are unspecified if \param{element-type}
  755. % is not compatible with the \term{element type} of the \term{array}
  756. % that the resulting \term{array} shares elements with.
  757. %% Redundant with Arguments and Values.
  758. %If \kwd{element-type} is not supplied, the elements are of type \t.
  759. If \param{initial-contents} is supplied, it is treated as for
  760. \funref{make-array}. In this case none of the original contents of
  761. \param{array} appears in the resulting \term{array}.
  762. \issue{ADJUST-ARRAY-FILL-POINTER}
  763. If \param{fill-pointer} is an \term{integer},
  764. it becomes the \term{fill pointer} for the resulting \term{array}.
  765. If \param{fill-pointer} is the symbol \t,
  766. it indicates that the size of the resulting \term{array}
  767. should be used as the \term{fill pointer}.
  768. If \param{fill-pointer} is \nil,
  769. it indicates that the \term{fill pointer} should be left as it is.
  770. \endissue{ADJUST-ARRAY-FILL-POINTER}
  771. If \param{displaced-to}
  772. %is supplied and
  773. \term{non-nil}, a \term{displaced array}
  774. is created. The resulting \term{array} shares its contents with the \term{array} given by
  775. \param{displaced-to}.
  776. The resulting \term{array} cannot contain more elements than the \term{array}
  777. it is displaced to.
  778. If \param{displaced-to} is not supplied or \nil,
  779. the resulting \term{array} is not a \term{displaced array}.
  780. If array $A$ is created displaced to array $B$ and subsequently
  781. array $B$ is given to \funref{adjust-array}, array $A$ will still be
  782. displaced to array $B$.
  783. Although \param{array} might be a \term{displaced array},
  784. the resulting \term{array} is not a \term{displaced array} unless
  785. \param{displaced-to} is supplied and not \nil.
  786. \issue{ADJUST-ARRAY-DISPLACEMENT}
  787. The interaction between \funref{adjust-array} and
  788. displaced \term{arrays}
  789. is as follows given three \term{arrays}, {\tt A}, {\tt B}, and~{\tt C}:
  790. \beginlist
  791. \itemitem{{\tt A} is not displaced before or after the call}
  792. \code
  793. (adjust-array A ...)
  794. \endcode
  795. The dimensions of {\tt A} are altered, and the
  796. contents rearranged as appropriate.
  797. Additional elements of {\tt A} are taken from
  798. \param{initial-element}.
  799. The use of \param{initial-contents} causes all old contents to be
  800. discarded.
  801. \itemitem{{\tt A} is not displaced before, but is displaced to
  802. {\tt C} after the call}
  803. \code
  804. (adjust-array A ... :displaced-to C)
  805. \endcode
  806. None of the original contents of {\tt A} appears in
  807. {\tt A} afterwards; {\tt A} now contains
  808. the contents of {\tt C}, without any rearrangement of {\tt C}.
  809. \itemitem{{\tt A} is displaced to {\tt B}
  810. before the call, and is displaced to {\tt C} after
  811. the call}
  812. \code
  813. (adjust-array A ... :displaced-to B)
  814. (adjust-array A ... :displaced-to C)
  815. \endcode
  816. {\tt B} and {\tt C} might be the same. The contents of {\tt B} do not appear in
  817. {\tt A} afterward unless such contents also happen to be in {\tt C} If
  818. \param{displaced-index-offset}
  819. is not supplied in the \funref{adjust-array} call, it defaults
  820. to zero; the old offset into {\tt B} is not retained.
  821. %% 17.6.0 11
  822. \itemitem{{\tt A} is displaced to {\tt B} before the call, but not displaced
  823. afterward.}
  824. \code
  825. (adjust-array A ... :displaced-to B)
  826. (adjust-array A ... :displaced-to nil)
  827. \endcode
  828. {\tt A} gets a
  829. new ``data region,'' and contents of {\tt B} are copied into it as appropriate to
  830. maintain the existing old contents; additional elements of {\tt A}
  831. are taken from
  832. \param{initial-element} if supplied. However,
  833. the use of \param{initial-contents} causes all old contents
  834. to be discarded.
  835. %If \param{array} is displaced
  836. %to another array \f{x} when \funref{adjust-array}
  837. %is applied to \param{array}, then afterwards neither
  838. %\param{array} nor the returned
  839. %result is displaced to \f{x} unless such displacement is explicitly
  840. %re-specified in the call to \funref{adjust-array}.
  841. \endlist
  842. \endissue{ADJUST-ARRAY-DISPLACEMENT}
  843. If \param{displaced-index-offset} is supplied,
  844. it specifies the offset
  845. of the resulting \term{array} from the beginning of
  846. the \term{array} that it is displaced to.
  847. If \param{displaced-index-offset} is not supplied, the offset is~0.
  848. The size of the resulting \term{array} plus the
  849. offset value cannot exceed the size of
  850. the \term{array} that it is displaced to.
  851. %% 17.6.0 5
  852. If only \param{new-dimensions}
  853. and an \param{initial-element} argument are supplied,
  854. those elements of \param{array} that
  855. are still in bounds appear in the resulting \term{array}. The elements of
  856. the resulting \term{array} that are not in the bounds of
  857. \term{array} are initialized
  858. to \param{initial-element}; if \param{initial-element} is not provided,
  859. \issue{UNINITIALIZED-ELEMENTS:CONSEQUENCES-UNDEFINED}
  860. %% This issue finally did pass at the March-93 meeting. -kmp 5-May-93
  861. % then the initial contents of any resulting \term{elements}
  862. % %%Rewritten to conform to the fact that issue UNINITIALIZED-ELEMENTS failed
  863. % %%to clarify this in the other direction because consensus was that this was well-defined
  864. % %%already. -kmp 15-Jan-92
  865. % %are undefined.
  866. % is \term{implementation-dependent}.
  867. the consequences of later reading any such new \term{element} of \param{new-array}
  868. before it has been initialized
  869. are undefined.
  870. \endissue{UNINITIALIZED-ELEMENTS:CONSEQUENCES-UNDEFINED}
  871. If \param{initial-contents} or \param{displaced-to} is supplied,
  872. then none of the original contents of \param{array} appears in the new \term{array}.
  873. %% 17.6.0 10
  874. \issue{ADJUST-ARRAY-NOT-ADJUSTABLE:IMPLICIT-COPY}
  875. %The following will be deleted:
  876. %
  877. %The consequences are unspecified
  878. %if \funref{adjust-array} is invoked with an \param{array} argument
  879. %that is not adjustable.
  880. \endissue{ADJUST-ARRAY-NOT-ADJUSTABLE:IMPLICIT-COPY}
  881. %If \param{fill-pointer} is \nil,
  882. %then the consequences are unspecified if
  883. %\param{array} has a \term{fill pointer}.
  884. The consequences are unspecified if \param{array} is adjusted
  885. to a size smaller than its \term{fill pointer} without supplying
  886. the \param{fill-pointer} argument so that its \term{fill-pointer}
  887. is properly adjusted in the process.
  888. If {\tt A} is displaced to {\tt B}, the consequences are unspecified
  889. if {\tt B} is adjusted in such a way that it no longer has enough elements
  890. to satisfy {\tt A}.
  891. \issue{ADJUST-ARRAY-NOT-ADJUSTABLE:IMPLICIT-COPY}
  892. If \funref{adjust-array} is applied to an \term{array} that is \term{actually adjustable},
  893. the \term{array} returned is \term{identical} to \param{array}.
  894. %% This was only needed when "\term{expressly adjustable}" was used in the previous sentence.
  895. % It is \term{implementation-dependent} whether \funref{adjust-array}
  896. % returns an \term{array} that is \term{identical} to its first argument for any
  897. % other \term{arrays}.
  898. If the \term{array} returned by \funref{adjust-array}
  899. is \term{distinct} from \param{array}, then the argument \param{array} is unchanged.
  900. \endissue{ADJUST-ARRAY-NOT-ADJUSTABLE:IMPLICIT-COPY}
  901. Note that if an \term{array} $A$ is displaced to another \term{array} $B$,
  902. and $B$ is displaced to another \term{array} $C$, and $B$ is altered by
  903. \funref{adjust-array}, $A$ must now refer to the adjust contents of $B$.
  904. This means that an implementation cannot collapse the chain to make $A$
  905. refer to $C$ directly and forget that the chain of reference passes through
  906. $B$. However, caching techniques are permitted as long as they preserve the
  907. semantics specified here.
  908. \label Examples::
  909. \code
  910. (adjustable-array-p
  911. (setq ada (adjust-array
  912. (make-array '(2 3)
  913. :adjustable t
  914. :initial-contents '((a b c) (1 2 3)))
  915. '(4 6)))) \EV T
  916. (array-dimensions ada) \EV (4 6)
  917. (aref ada 1 1) \EV 2
  918. (setq beta (make-array '(2 3) :adjustable t))
  919. \EV #2A((NIL NIL NIL) (NIL NIL NIL))
  920. (adjust-array beta '(4 6) :displaced-to ada)
  921. \EV #2A((A B C NIL NIL NIL)
  922. (1 2 3 NIL NIL NIL)
  923. (NIL NIL NIL NIL NIL NIL)
  924. (NIL NIL NIL NIL NIL NIL))
  925. (array-dimensions beta) \EV (4 6)
  926. (aref beta 1 1) \EV 2
  927. \endcode
  928. %% 17.6.0 11
  929. Suppose that the 4-by-4 array in \f{m} looks like this:
  930. \code
  931. #2A(( alpha beta gamma delta )
  932. ( epsilon zeta eta theta )
  933. ( iota kappa lambda mu )
  934. ( nu xi omicron pi ))
  935. \endcode
  936. Then the result of
  937. \code
  938. (adjust-array m '(3 5) :initial-element 'baz)
  939. \endcode
  940. is a 3-by-5 array with contents
  941. \code
  942. #2A(( alpha beta gamma delta baz )
  943. ( epsilon zeta eta theta baz )
  944. ( iota kappa lambda mu baz ))
  945. \endcode
  946. \label Affected By:\None!
  947. %%I don't think this sort of thing is worthwhile to note. -kmp 7-Jan-91
  948. %How \param{array} was created.
  949. \label Exceptional Situations::
  950. An error \oftype{error} is signaled if \param{fill-pointer} is supplied
  951. and \term{non-nil} but \param{array} has no \term{fill pointer}.
  952. %\issue{ADJUST-ARRAY-NOT-ADJUSTABLE:DONKEY}
  953. %An error \oftype{error} is signaled if an attempt
  954. % is made to adjust an \param{array} that is not adjustable (that is, an
  955. % \param{array} for which \funref{adjustable-array-p} returns \term{false}).
  956. %
  957. %\endissue{ADJUST-ARRAY-NOT-ADJUSTABLE:DONKEY}
  958. \label See Also::
  959. \funref{adjustable-array-p}, \funref{make-array},
  960. \funref{array-dimension-limit}, \funref{array-total-size-limit},
  961. \typeref{array}
  962. \label Notes:\None.
  963. %\issue{ADJUST-ARRAY-NOT-ADJUSTABLE:DONKEY}
  964. %\funref{adjustable-array-p} is an appropriate
  965. % predicate to determine whether \funref{adjust-array} will reliably succeed.
  966. %\endissue{ADJUST-ARRAY-NOT-ADJUSTABLE:DONKE Y}
  967. %% Sandra thinks this is redundant.
  968. % \issue{ADJUST-ARRAY-NOT-ADJUSTABLE:IMPLICIT-COPY}
  969. % The value returned by \funref{adjust-array} might not be \term{identical}
  970. % to the argument \param{array}.
  971. % \endissue{ADJUST-ARRAY-NOT-ADJUSTABLE:IMPLICIT-COPY}
  972. \endcom
  973. %%% ========== ADJUSTABLE-ARRAY-P
  974. \begincom{adjustable-array-p}\ftype{Function}
  975. %!!! Barmar's review comments of this were made on the basis of document that
  976. % did not include various cleanups. This should be re-reviewed carefully later.
  977. % -kmp 17-Dec-90
  978. \label Syntax::
  979. \DefunWithValues adjustable-array-p {array} {generalized-boolean}
  980. \label Arguments and Values::
  981. \param{array}---an \term{array}.
  982. \param{generalized-boolean}---a \term{generalized boolean}.
  983. \label Description::
  984. \issue{ADJUST-ARRAY-NOT-ADJUSTABLE:IMPLICIT-COPY}
  985. %% 17.3.0 13
  986. Returns true if and only if \funref{adjust-array} could return a \term{value}
  987. which is \term{identical} to \param{array} when given that \term{array} as its
  988. first \term{argument}.
  989. \endissue{ADJUST-ARRAY-NOT-ADJUSTABLE:IMPLICIT-COPY}
  990. \label Examples::
  991. \code
  992. (adjustable-array-p
  993. (make-array 5
  994. :element-type 'character
  995. :adjustable t
  996. :fill-pointer 3)) \EV \term{true}
  997. (adjustable-array-p (make-array 4)) \EV \term{implementation-dependent}
  998. \endcode
  999. \label Affected By:\None.
  1000. \label Exceptional Situations::
  1001. Should signal an error \oftype{type-error} if its argument is not an \term{array}.
  1002. \label See Also::
  1003. \funref{adjust-array}, \funref{make-array}
  1004. \label Notes:\None.
  1005. %\issue{ADJUST-ARRAY-NOT-ADJUSTABLE:DONKEY}
  1006. %
  1007. %
  1008. % An \term{array} ``is adjustable''
  1009. %if {\tt (adjustable-array-p \term{array})} is \term{true}.
  1010. % The adjustability of an \term{array} has no necessary
  1011. % relation to any value that was given (or not given) by the \kwd{adjustable}
  1012. % \term{argument}
  1013. % in the call to \funref{make-array} that created the \term{array}.
  1014. %
  1015. % There is no portable way to create a non-adjustable
  1016. % \term{array} (that is, an \term{array} for which \funref{adjustable-array-p} is
  1017. % guaranteed to return \term{false}).
  1018. %\endissue{ADJUST-ARRAY-NOT-ADJUSTABLE:DONKEY}
  1019. \endcom
  1020. %%% ========== AREF
  1021. \begincom{aref}\ftype{Accessor}
  1022. \label Syntax::
  1023. \DefunWithValues aref {array {\rest} subscripts} {element}
  1024. \Defsetf aref {array {\rest} subscripts} {new-element}
  1025. \label Arguments and Values::
  1026. \param{array}---an \term{array}.
  1027. \issue{ARRAY-DIMENSION-LIMIT-IMPLICATIONS:ALL-FIXNUM}
  1028. \param{subscripts}---a \term{list} of \term{valid array indices} for the \param{array}.
  1029. \endissue{ARRAY-DIMENSION-LIMIT-IMPLICATIONS:ALL-FIXNUM}
  1030. \param{element}, \param{new-element}---an \term{object}.
  1031. \label Description::
  1032. %% 17.2.0 3
  1033. \term{Accesses} the \param{array} \term{element} specified by the \param{subscripts}.
  1034. If no \param{subscripts} are supplied and \param{array} is zero rank,
  1035. \funref{aref} \term{accesses} the sole element of \param{array}.
  1036. %% 17.2.0 4
  1037. \funref{aref} ignores \term{fill pointers}.
  1038. It is permissible to use \funref{aref}
  1039. to \term{access} any \param{array} \term{element},
  1040. whether \term{active} or not.
  1041. %% This is implied by the use of "access" above.
  1042. % %% 17.2.0 5
  1043. % \macref{setf} can be used with \funref{aref} to destructively replace
  1044. % an \term{array} element with a new value.
  1045. \label Examples::
  1046. %% 2.5.0 6
  1047. If the variable \f{foo} names a 3-by-5 array,
  1048. then the first index could be 0, 1, or 2, and then second index
  1049. could be 0, 1, 2, 3, or 4. The array elements can be referred to by using
  1050. \thefunction{aref}; for example, \f{(aref foo 2 1)}
  1051. refers to element (2, 1) of the array.
  1052. \code
  1053. (aref (setq alpha (make-array 4)) 3) \EV \term{implementation-dependent}
  1054. (setf (aref alpha 3) 'sirens) \EV SIRENS
  1055. (aref alpha 3) \EV SIRENS
  1056. (aref (setq beta (make-array '(2 4)
  1057. :element-type '(unsigned-byte 2)
  1058. :initial-contents '((0 1 2 3) (3 2 1 0))))
  1059. 1 2) \EV 1
  1060. (setq gamma '(0 2))
  1061. (apply #'aref beta gamma) \EV 2
  1062. (setf (apply #'aref beta gamma) 3) \EV 3
  1063. (apply #'aref beta gamma) \EV 3
  1064. (aref beta 0 2) \EV 3
  1065. \endcode
  1066. \label Affected By:\None.
  1067. \label Exceptional Situations:\None.
  1068. \label See Also::
  1069. \funref{bit},
  1070. \funref{char},
  1071. \funref{elt},
  1072. \funref{row-major-aref},
  1073. \funref{svref},
  1074. \issue{CONSTANT-MODIFICATION:DISALLOW}
  1075. {\secref\ConstantModification}
  1076. \endissue{CONSTANT-MODIFICATION:DISALLOW}
  1077. \label Notes:\None.
  1078. \endcom
  1079. %%% ========== ARRAY-DIMENSION
  1080. \begincom{array-dimension}\ftype{Function}
  1081. \label Syntax::
  1082. \DefunWithValues array-dimension {array axis-number} {dimension}
  1083. \label Arguments and Values::
  1084. \param{array}---an \term{array}.
  1085. \param{axis-number}---an \term{integer} greater than or equal to zero
  1086. and less than the \term{rank} of the \param{array}.
  1087. % Barmar observes that nothing requires the implementation to enforce ARRAY-DIMENSION-LIMIT.
  1088. % It's a requirement on the user to be prepared to lose if he exceeds it,
  1089. % but it is not a requirement on the implementation to make him lose in that case.
  1090. \param{dimension}---a non-negative \term{integer}.
  1091. \label Description::
  1092. %!!! (array-dimension (make-array nil) ??)
  1093. %% 17.3.0 6
  1094. \funref{array-dimension} returns the \param{axis-number}
  1095. \term{dimension}\meaning{1} of \param{array}.
  1096. %This next is implied by the definition of dimension, but retained for now for safety. -kmp
  1097. (Any \term{fill pointer} is ignored.)
  1098. \label Examples::
  1099. \code
  1100. (array-dimension (make-array 4) 0) \EV 4
  1101. (array-dimension (make-array '(2 3)) 1) \EV 3
  1102. \endcode
  1103. \label Affected By::
  1104. None.
  1105. \label Exceptional Situations:\None.
  1106. \label See Also::
  1107. \funref{array-dimensions}, \funref{length}
  1108. \label Notes::
  1109. \code
  1110. (array-dimension array n) \EQ (nth n (array-dimensions array))
  1111. \endcode
  1112. \endcom
  1113. %%% ========== ARRAY-DIMENSIONS
  1114. \begincom{array-dimensions}\ftype{Function}
  1115. \label Syntax::
  1116. \DefunWithValues array-dimensions {array} {dimensions}
  1117. \label Arguments and Values::
  1118. \param{array}---an \term{array}.
  1119. % Barmar observes that nothing requires the implementation to enforce ARRAY-DIMENSION-LIMIT.
  1120. % It's a requirement on the user to be prepared to lose if he exceeds it,
  1121. % but it is not a requirement on the implementation to make him lose in that case.
  1122. \param{dimensions}---a \term{list} of \term{integers}.
  1123. \label Description::
  1124. %% 17.3.0 8
  1125. Returns a \term{list} of the \term{dimensions} of \param{array}.
  1126. (If \param{array} is a \term{vector} with a \term{fill pointer},
  1127. that \term{fill pointer} is ignored.)
  1128. \label Examples::
  1129. \code
  1130. (array-dimensions (make-array 4)) \EV (4)
  1131. (array-dimensions (make-array '(2 3))) \EV (2 3)
  1132. (array-dimensions (make-array 4 :fill-pointer 2)) \EV (4)
  1133. \endcode
  1134. \label Affected By:\None!
  1135. \label Exceptional Situations::
  1136. Should signal an error \oftype{type-error} if its argument is not an \term{array}.
  1137. \label See Also::
  1138. \funref{array-dimension}
  1139. %% Per X3J13. -kmp 05-Oct-93
  1140. \label Notes:\None.
  1141. \endcom
  1142. %%% ========== ARRAY-ELEMENT-TYPE
  1143. \begincom{array-element-type}\ftype{Function}
  1144. \label Syntax::
  1145. \DefunWithValues array-element-type {array} {typespec}
  1146. \label Arguments and Values::
  1147. \param{array}---an \term{array}.
  1148. \param{typespec}---a \term{type specifier}.
  1149. \label Description::
  1150. %% 17.3.0 3
  1151. \issue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  1152. Returns a \term{type specifier} which represents the \term{actual array element type}
  1153. of the array, which is the set of \term{objects} that such an \param{array} can hold.
  1154. %Barmar points out that this is redundant.
  1155. % after upgrading.
  1156. (Because of \term{array} \term{upgrading}, this \term{type specifier} can in
  1157. some cases denote a \term{supertype} of the \term{expressed array element type}
  1158. of the \param{array}.)
  1159. %\term{type} requested by the user when \param{array} was created.
  1160. \endissue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  1161. \label Examples::
  1162. \code
  1163. (array-element-type (make-array 4)) \EV T
  1164. (array-element-type (make-array 12 :element-type '(unsigned-byte 8)))
  1165. \EV \term{implementation-dependent}
  1166. (array-element-type (make-array 12 :element-type '(unsigned-byte 5)))
  1167. \EV \term{implementation-dependent}
  1168. \endcode
  1169. \code
  1170. (array-element-type (make-array 5 :element-type '(mod 5)))
  1171. \endcode
  1172. could be \f{(mod 5)}, \f{(mod 8)}, \f{fixnum}, \f{t}, or any other
  1173. type of which \f{(mod 5)} is a \term{subtype}.
  1174. \label Affected By::
  1175. The \term{implementation}.
  1176. \label Exceptional Situations::
  1177. Should signal an error \oftype{type-error} if its argument is not an \term{array}.
  1178. \label See Also::
  1179. \typeref{array},
  1180. \funref{make-array},
  1181. \funref{subtypep},
  1182. \funref{upgraded-array-element-type}
  1183. \label Notes:\None.
  1184. \endcom
  1185. %%% ========== ARRAY-HAS-FILL-POINTER-P
  1186. \begincom{array-has-fill-pointer-p}\ftype{Function}
  1187. \label Syntax::
  1188. \DefunWithValues array-has-fill-pointer-p {array} {generalized-boolean}
  1189. \label Arguments and Values::
  1190. \param{array}---an \term{array}.
  1191. \param{generalized-boolean}---a \term{generalized boolean}.
  1192. \label Description::
  1193. %% 17.5.0 5
  1194. Returns \term{true} if \param{array} has a \term{fill pointer};
  1195. otherwise returns \term{false}.
  1196. \label Examples::
  1197. \code
  1198. (array-has-fill-pointer-p (make-array 4)) \EV \term{implementation-dependent}
  1199. (array-has-fill-pointer-p (make-array '(2 3))) \EV \term{false}
  1200. (array-has-fill-pointer-p
  1201. (make-array 8
  1202. :fill-pointer 2
  1203. :initial-element 'filler)) \EV \term{true}
  1204. \endcode
  1205. \label Affected By:\None!
  1206. \label Exceptional Situations::
  1207. Should signal an error \oftype{type-error} if its argument is not an \term{array}.
  1208. \label See Also::
  1209. \funref{make-array}, \funref{fill-pointer}
  1210. \label Notes::
  1211. Since \term{arrays} of \term{rank} other than one cannot have a \term{fill pointer},
  1212. \funref{array-has-fill-pointer-p} always returns \nil\ when its argument
  1213. is such an array.
  1214. \endcom
  1215. %--------------------
  1216. \begincom{array-displacement}\ftype{Function}
  1217. \issue{DISPLACED-ARRAY-PREDICATE:ADD}
  1218. \label Syntax::
  1219. \DefunWithValues array-displacement {array} {displaced-to, displaced-index-offset}
  1220. \label Arguments and Values::
  1221. \param{array}---an \term{array}.
  1222. \param{displaced-to}---an \param{array} or \nil.
  1223. \param{displaced-index-offset}---a non-negative \term{fixnum}.
  1224. \label Description::
  1225. If the \param{array} is a \term{displaced array},
  1226. returns the \term{values} of the \kwd{displaced-to} and \kwd{displaced-index-offset}
  1227. options
  1228. for the \term{array} (\seefuns{make-array} and \funref{adjust-array}).
  1229. If the \param{array} is not a \term{displaced array},
  1230. \nil\ and \f{0} are returned.
  1231. If \funref{array-displacement} is called on an \param{array}
  1232. for which a \term{non-nil} \term{object} was provided as the
  1233. \kwd{displaced-to} \term{argument} to \funref{make-array}
  1234. or \funref{adjust-array}, it must return that \term{object}
  1235. as its first value. It is \term{implementation-dependent}
  1236. whether \funref{array-displacement} returns a \term{non-nil}
  1237. \term{primary value} for any other \param{array}.
  1238. \label Examples::
  1239. \code
  1240. (setq a1 (make-array 5)) \EV #<ARRAY 5 simple 46115576>
  1241. (setq a2 (make-array 4 :displaced-to a1
  1242. :displaced-index-offset 1))
  1243. \EV #<ARRAY 4 indirect 46117134>
  1244. (array-displacement a2)
  1245. \EV #<ARRAY 5 simple 46115576>, 1
  1246. (setq a3 (make-array 2 :displaced-to a2
  1247. :displaced-index-offset 2))
  1248. \EV #<ARRAY 2 indirect 46122527>
  1249. (array-displacement a3)
  1250. \EV #<ARRAY 4 indirect 46117134>, 2
  1251. \endcode
  1252. \label Affected By:\None!
  1253. \label Exceptional Situations::
  1254. \Shouldchecktype{array}{an \term{array}}
  1255. \label See Also::
  1256. \funref{make-array}
  1257. %% Per X3J13. -kmp 05-Oct-93
  1258. \label Notes:\None.
  1259. \endissue{DISPLACED-ARRAY-PREDICATE:ADD}
  1260. \endcom
  1261. %%% ========== ARRAY-IN-BOUNDS-P
  1262. \begincom{array-in-bounds-p}\ftype{Function}
  1263. \label Syntax::
  1264. \DefunWithValues array-in-bounds-p {array {\rest} subscripts} {generalized-boolean}
  1265. \label Arguments and Values::
  1266. \param{array}---an \term{array}.
  1267. % Note that they needn't be valid array indices,
  1268. % since that would make this function a lot less interesting!
  1269. \param{subscripts}---a list of \term{integers}
  1270. of length equal to the \term{rank} of the \term{array}.
  1271. \param{generalized-boolean}---a \term{generalized boolean}.
  1272. \label Description::
  1273. %% 17.3.0 10
  1274. Returns \term{true} if the \param{subscripts} are all in bounds for \param{array};
  1275. otherwise returns \term{false}.
  1276. (If \param{array} is a \term{vector} with a \term{fill pointer},
  1277. that \term{fill pointer} is ignored.)
  1278. \label Examples::
  1279. \code
  1280. (setq a (make-array '(7 11) :element-type 'string-char))
  1281. (array-in-bounds-p a 0 0) \EV \term{true}
  1282. (array-in-bounds-p a 6 10) \EV \term{true}
  1283. (array-in-bounds-p a 0 -1) \EV \term{false}
  1284. (array-in-bounds-p a 0 11) \EV \term{false}
  1285. (array-in-bounds-p a 7 0) \EV \term{false}
  1286. \endcode
  1287. \label Affected By:\None.
  1288. \label Exceptional Situations:\None.
  1289. \label See Also::
  1290. \funref{array-dimensions}
  1291. \label Notes::
  1292. \code
  1293. (array-in-bounds-p array subscripts)
  1294. \EQ (and (not (some #'minusp (list subscripts)))
  1295. (every #'< (list subscripts) (array-dimensions array)))
  1296. \endcode
  1297. \endcom
  1298. %%% ========== ARRAY-RANK
  1299. \begincom{array-rank}\ftype{Function}
  1300. \label Syntax::
  1301. \DefunWithValues array-rank {array} {rank}
  1302. \label Arguments and Values::
  1303. \param{array}---an \term{array}.
  1304. % Barmar observes that nothing requires the implementation to enforce ARRAY-RANK-LIMIT.
  1305. % It's a requirement on the user to be prepared to lose if he exceeds it,
  1306. % but it is not a requirement on the implementation to make him lose in that case.
  1307. \param{rank}---a non-negative \term{integer}.
  1308. \label Description::
  1309. %% 17.3.0 4
  1310. Returns the number of \term{dimensions} of \param{array}.
  1311. \label Examples::
  1312. \code
  1313. (array-rank (make-array '())) \EV 0
  1314. (array-rank (make-array 4)) \EV 1
  1315. (array-rank (make-array '(4))) \EV 1
  1316. (array-rank (make-array '(2 3))) \EV 2
  1317. \endcode
  1318. \label Affected By:\None.
  1319. \label Exceptional Situations::
  1320. Should signal an error \oftype{type-error} if its argument is not an \term{array}.
  1321. \label See Also::
  1322. \conref{array-rank-limit}, \funref{make-array}
  1323. \label Notes:\None.
  1324. \endcom
  1325. %%% ========== ARRAY-ROW-MAJOR-INDEX
  1326. \begincom{array-row-major-index}\ftype{Function}
  1327. \label Syntax::
  1328. \DefunWithValues array-row-major-index {array {\rest} subscripts} {index}
  1329. \label Arguments and Values::
  1330. \param{array}---an \term{array}.
  1331. \param{subscripts}---a \term{list} of \term{valid array indices} for the \param{array}.
  1332. \param{index}---a \term{valid array row-major index} for the \param{array}.
  1333. \label Description::
  1334. %% 17.3.0 11
  1335. Computes the position according to the row-major ordering of \param{array}
  1336. for the element that is specified by \param{subscripts}, and returns the
  1337. offset of the element in the computed position from the beginning of \param{array}.
  1338. For a one-dimensional \param{array},
  1339. the result of \funref{array-row-major-index}
  1340. equals \param{subscript}.
  1341. \funref{array-row-major-index} ignores \term{fill pointers}.
  1342. \label Examples::
  1343. \code
  1344. (setq a (make-array '(4 7) :element-type '(unsigned-byte 8)))
  1345. (array-row-major-index a 1 2) \EV 9
  1346. (array-row-major-index
  1347. (make-array '(2 3 4)
  1348. :element-type '(unsigned-byte 8)
  1349. :displaced-to a
  1350. :displaced-index-offset 4)
  1351. 0 2 1) \EV 9
  1352. \endcode
  1353. \label Affected By:\None.
  1354. \label Exceptional Situations:\None.
  1355. \label See Also:\None.
  1356. \label Notes::
  1357. %% 17.3.0 12
  1358. A possible definition of \funref{array-row-major-index},
  1359. with no error-checking, is
  1360. \code
  1361. (defun array-row-major-index (a &rest subscripts)
  1362. (apply #'+ (maplist #'(lambda (x y)
  1363. (* (car x) (apply #'* (cdr y))))
  1364. subscripts
  1365. (array-dimensions a))))
  1366. \endcode
  1367. \endcom
  1368. %%% ========== ARRAY-TOTAL-SIZE
  1369. \begincom{array-total-size}\ftype{Function}
  1370. \label Syntax::
  1371. \DefunWithValues array-total-size {array} {size}
  1372. \label Arguments and Values::
  1373. \param{array}---an \term{array}.
  1374. % Barmar observes that nothing requires the implementation to enforce ARRAY-TOTAL-SIZE-LIMIT.
  1375. % It's a requirement on the user to be prepared to lose if he exceeds it,
  1376. % but it is not a requirement on the implementation to make him lose in that case.
  1377. \param{size}---a non-negative \term{integer}.
  1378. \label Description::
  1379. %% 17.3.0 9
  1380. Returns the \term{array total size} of the \param{array}.
  1381. \label Examples::
  1382. \code
  1383. (array-total-size (make-array 4)) \EV 4
  1384. (array-total-size (make-array 4 :fill-pointer 2)) \EV 4
  1385. (array-total-size (make-array 0)) \EV 0
  1386. (array-total-size (make-array '(4 2))) \EV 8
  1387. (array-total-size (make-array '(4 0))) \EV 0
  1388. (array-total-size (make-array '())) \EV 1
  1389. \endcode
  1390. \label Affected By:\None!
  1391. \label Exceptional Situations::
  1392. Should signal an error \oftype{type-error} if its argument is not an \term{array}.
  1393. \label See Also::
  1394. \funref{make-array}, \funref{array-dimensions}
  1395. \label Notes::
  1396. If the \param{array} is a \term{vector} with a \term{fill pointer},
  1397. the \term{fill pointer} is ignored when calculating the \term{array total size}.
  1398. Since the product of no arguments is one, the \term{array total size} of a
  1399. zero-dimensional \term{array} is one.
  1400. \code
  1401. (array-total-size x)
  1402. \EQ (apply #'* (array-dimensions x))
  1403. \EQ (reduce #'* (array-dimensions x))
  1404. \endcode
  1405. \endcom
  1406. %%% ========== ARRAYP
  1407. \begincom{arrayp}\ftype{Function}
  1408. \label Syntax::
  1409. \DefunWithValues arrayp {object} {generalized-boolean}
  1410. \label Arguments and Values::
  1411. \param{object}---an \term{object}.
  1412. \param{generalized-boolean}---a \term{generalized boolean}.
  1413. \label Description::
  1414. %% 6.2.2 24
  1415. \TypePredicate{object}{array}
  1416. \label Examples::
  1417. \code
  1418. (arrayp (make-array '(2 3 4) :adjustable t)) \EV \term{true}
  1419. (arrayp (make-array 6)) \EV \term{true}
  1420. (arrayp #*1011) \EV \term{true}
  1421. (arrayp "hi") \EV \term{true}
  1422. (arrayp 'hi) \EV \term{false}
  1423. (arrayp 12) \EV \term{false}
  1424. \endcode
  1425. \label Affected By:\None.
  1426. \label Exceptional Situations:\None!
  1427. \label See Also::
  1428. \funref{typep}
  1429. \label Notes::
  1430. \code
  1431. (arrayp \param{object}) \EQ (typep \param{object} 'array)
  1432. \endcode
  1433. \endcom
  1434. %%% ========== FILL-POINTER
  1435. \begincom{fill-pointer}\ftype{Accessor}
  1436. \label Syntax::
  1437. %% 17.5.0 7
  1438. \DefunWithValues fill-pointer {vector} {fill-pointer}
  1439. \Defsetf fill-pointer {vector} {new-fill-pointer}
  1440. \label Arguments and Values::
  1441. \param{vector}---a \term{vector} with a \term{fill pointer}.
  1442. \param{fill-pointer}, \param{new-fill-pointer}---a \term{valid fill pointer}
  1443. for the \param{vector}.
  1444. \label Description::
  1445. %% 17.5.0 6
  1446. \term{Accesses} the \term{fill pointer} of \param{vector}.
  1447. \label Examples::
  1448. \code
  1449. (setq a (make-array 8 :fill-pointer 4)) \EV #(NIL NIL NIL NIL)
  1450. (fill-pointer a) \EV 4
  1451. (dotimes (i (length a)) (setf (aref a i) (* i i))) \EV NIL
  1452. a \EV #(0 1 4 9)
  1453. (setf (fill-pointer a) 3) \EV 3
  1454. (fill-pointer a) \EV 3
  1455. a \EV #(0 1 4)
  1456. (setf (fill-pointer a) 8) \EV 8
  1457. a \EV #(0 1 4 9 NIL NIL NIL NIL)
  1458. \endcode
  1459. \label Side Effects:\None!
  1460. \label Affected By:\None!
  1461. \label Exceptional Situations::
  1462. \Shouldchecktype{vector}{a \term{vector} with a \term{fill pointer}}
  1463. \label See Also::
  1464. \funref{make-array}, \funref{length}
  1465. \label Notes::
  1466. There is no \term{operator} that will remove a \term{vector}'s \term{fill pointer}.
  1467. \endcom
  1468. %%% ========== ROW-MAJOR-AREF
  1469. \begincom{row-major-aref}\ftype{Accessor}
  1470. \issue{AREF-1D}
  1471. \label Syntax::
  1472. \DefunWithValues row-major-aref {array index} {element}
  1473. \Defsetf row-major-aref {array index} {new-element}
  1474. \label Arguments and Values::
  1475. \param{array}---an \term{array}.
  1476. \issue{ARRAY-DIMENSION-LIMIT-IMPLICATIONS:ALL-FIXNUM}
  1477. \param{index}---a \term{valid array row-major index} for the \param{array}.
  1478. \endissue{ARRAY-DIMENSION-LIMIT-IMPLICATIONS:ALL-FIXNUM}
  1479. \param{element}, \param{new-element}---an \term{object}.
  1480. \label Description::
  1481. Considers \term{array} as a \term{vector} by viewing its \term{elements}
  1482. in row-major order, and returns the \term{element} of that \term{vector}
  1483. which is referred to by the given \param{index}.
  1484. \funref{row-major-aref} is valid for use with \macref{setf}.
  1485. \label Examples:\None.
  1486. \label Side Effects:\None.
  1487. \label Affected By:\None.
  1488. \label Exceptional Situations:\None.
  1489. \label See Also::
  1490. \funref{aref},
  1491. \funref{array-row-major-index}
  1492. \label Notes::
  1493. \code
  1494. (row-major-aref array index) \EQ
  1495. (aref (make-array (array-total-size array)
  1496. :displaced-to array
  1497. :element-type (array-element-type array))
  1498. index)
  1499. (aref array i1 i2 ...) \EQ
  1500. (row-major-aref array (array-row-major-index array i1 i2))
  1501. \endcode
  1502. \endissue{AREF-1D}
  1503. \endcom
  1504. %%% ========== UPGRADED-ARRAY-ELEMENT-TYPE
  1505. \begincom{upgraded-array-element-type}\ftype{Function}
  1506. \issue{SUBTYPEP-ENVIRONMENT:ADD-ARG}
  1507. \issue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  1508. \label Syntax::
  1509. \DefunWithValues upgraded-array-element-type {typespec {\opt} environment}
  1510. {upgraded-typespec}
  1511. \label Arguments and Values::
  1512. \param{typespec}---a \term{type specifier}.
  1513. \param{environment}---an \term{environment} \term{object}.
  1514. \Default{\nil, denoting the \term{null lexical environment}
  1515. and the current \term{global environment}}
  1516. %!!! Need to say what happens with the environment.
  1517. \param{upgraded-typespec}---a \term{type specifier}.
  1518. \label Description::
  1519. Returns the \term{element type} of
  1520. the most \term{specialized} \term{array} representation capable of
  1521. holding items of the \term{type} denoted by \param{typespec}.
  1522. %Added by KMP in response to a Barmar comment. -kmp 29-Jul-91
  1523. The \param{typespec} is a \term{subtype} of
  1524. (and possibly \term{type equivalent} to)
  1525. the \param{upgraded-typespec}.
  1526. If \param{typespec} is \typeref{bit},
  1527. the result is \term{type equivalent} to \f{bit}.
  1528. \issue{CHARACTER-VS-CHAR:LESS-INCONSISTENT-SHORT}
  1529. If \param{typespec} is \typeref{base-char},
  1530. the result is \term{type equivalent} to \f{base-char}.
  1531. \endissue{CHARACTER-VS-CHAR:LESS-INCONSISTENT-SHORT}
  1532. If \param{typespec} is \typeref{character},
  1533. the result is \term{type equivalent} to \f{character}.
  1534. The purpose of \funref{upgraded-array-element-type} is to reveal how
  1535. an implementation does its \term{upgrading}.
  1536. The \param{environment} is used to expand any \term{derived type specifiers}
  1537. that are mentioned in the \param{typespec}.
  1538. \label Examples:\None.
  1539. \label Side Effects:\None.
  1540. \label Affected By:\None.
  1541. \label Exceptional Situations:\None.
  1542. \label See Also::
  1543. \funref{array-element-type},
  1544. \funref{make-array}
  1545. \label Notes::
  1546. Except for storage allocation consequences and dealing correctly with the
  1547. optional \param{environment} \term{argument},
  1548. \funref{upgraded-array-element-type} could be defined as:
  1549. \code
  1550. (defun upgraded-array-element-type (type &optional environment)
  1551. (array-element-type (make-array 0 :element-type type)))
  1552. \endcode
  1553. \endissue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  1554. \endissue{SUBTYPEP-ENVIRONMENT:ADD-ARG}
  1555. \endcom
  1556. %%% ========== ARRAY-DIMENSION-LIMIT
  1557. \begincom{array-dimension-limit}\ftype{Constant Variable}
  1558. \label Constant Value::
  1559. A positive
  1560. \issue{FIXNUM-NON-PORTABLE:TIGHTEN-DEFINITION}
  1561. \term{fixnum},
  1562. \endissue{FIXNUM-NON-PORTABLE:TIGHTEN-DEFINITION}
  1563. the exact magnitude of which is \term{implementation-dependent},
  1564. but which is not less than \f{1024}.
  1565. \label Description::
  1566. %% 17.1.0 18
  1567. The upper exclusive bound on each individual \term{dimension} of an \term{array}.
  1568. \label Examples:\None.
  1569. \label See Also::
  1570. \funref{make-array}
  1571. \label Notes:\None.
  1572. \endcom
  1573. %%% ========== ARRAY-RANK-LIMIT
  1574. \begincom{array-rank-limit}\ftype{Constant Variable}
  1575. \label Constant Value::
  1576. A positive
  1577. \issue{ARRAY-DIMENSION-LIMIT-IMPLICATIONS:ALL-FIXNUM}
  1578. \term{fixnum},
  1579. \endissue{ARRAY-DIMENSION-LIMIT-IMPLICATIONS:ALL-FIXNUM}
  1580. the exact magnitude of which is \term{implementation-dependent},
  1581. but which is not less than \f{8}.
  1582. \label Description::
  1583. %% 17.1.0 17
  1584. The upper exclusive bound on the \term{rank} of an \term{array}.
  1585. \label Examples:\None.
  1586. \label See Also::
  1587. \funref{make-array}
  1588. \label Notes:\None.
  1589. \endcom
  1590. %%% ========== ARRAY-TOTAL-SIZE-LIMIT
  1591. \begincom{array-total-size-limit}\ftype{Constant Variable}
  1592. \label Constant Value::
  1593. A positive
  1594. \issue{ARRAY-DIMENSION-LIMIT-IMPLICATIONS:ALL-FIXNUM}
  1595. \term{fixnum},
  1596. \endissue{ARRAY-DIMENSION-LIMIT-IMPLICATIONS:ALL-FIXNUM}
  1597. the exact magnitude of which is \term{implementation-dependent},
  1598. but which is not less than \f{1024}.
  1599. \label Description::
  1600. %% 17.1.0 19
  1601. The upper exclusive bound on the \term{array total size} of an \term{array}.
  1602. %% 17.1.0 20
  1603. The actual limit on the \term{array total size}
  1604. imposed by the \term{implementation}
  1605. might vary according the \term{element type} of the \term{array};
  1606. in this case, the value of \conref{array-total-size-limit}
  1607. will be the smallest of these possible limits.
  1608. \label Examples:\None.
  1609. \label See Also::
  1610. \funref{make-array}, \funref{array-element-type}
  1611. \label Notes:\None.
  1612. \endcom
  1613. %-------------------- Vectors --------------------
  1614. %%% ========== SIMPLE-VECTOR-P
  1615. \begincom{simple-vector-p}\ftype{Function}
  1616. \label Syntax::
  1617. \DefunWithValues simple-vector-p {object} {generalized-boolean}
  1618. \label Arguments and Values::
  1619. \param{object}---an \term{object}.
  1620. \param{generalized-boolean}---a \term{generalized boolean}.
  1621. \label Description::
  1622. %% 6.2.2 21
  1623. \TypePredicate{object}{simple-vector}.
  1624. \label Examples::
  1625. \code
  1626. (simple-vector-p (make-array 6)) \EV \term{true}
  1627. (simple-vector-p "aaaaaa") \EV \term{false}
  1628. (simple-vector-p (make-array 6 :fill-pointer t)) \EV \term{false}
  1629. \endcode
  1630. \label Side Effects:\None.
  1631. \label Affected By:\None.
  1632. \label Exceptional Situations:\None!
  1633. \label See Also::
  1634. \typeref{simple-vector}
  1635. \label Notes::
  1636. \code
  1637. (simple-vector-p \param{object}) \EQ (typep \param{object} 'simple-vector)
  1638. \endcode
  1639. \endcom
  1640. %%% ========== SVREF
  1641. \begincom{svref}\ftype{Accessor}
  1642. \label Syntax::
  1643. \DefunWithValues svref {simple-vector index} {element}
  1644. \Defsetf svref {simple-vector index} {new-element}
  1645. \label Arguments and Values::
  1646. \param{simple-vector}---a \term{simple vector}.
  1647. \param{index}---a \term{valid array index} for the \param{simple-vector}.
  1648. \param{element}, \param{new-element}---an \term{object}
  1649. (whose \term{type} is a \term{subtype}
  1650. of the \term{array element type} of the \param{simple-vector}).
  1651. \label Description::
  1652. %% 17.2.0 7
  1653. \term{Accesses} the \term{element} of \param{simple-vector} specified by \param{index}.
  1654. %% Implied by use of "Access". -kmp 15-Jan-92
  1655. % %% 17.2.0 7
  1656. % \macref{setf} may be used with \funref{svref} to destructively replace
  1657. % a \term{simple vector} element with a new value.
  1658. \label Examples::
  1659. \code
  1660. (simple-vector-p (setq v (vector 1 2 'sirens))) \EV \term{true}
  1661. (svref v 0) \EV 1
  1662. (svref v 2) \EV SIRENS
  1663. (setf (svref v 1) 'newcomer) \EV NEWCOMER
  1664. v \EV #(1 NEWCOMER SIRENS)
  1665. \endcode
  1666. \label Side Effects:\None.
  1667. \label Affected By:\None.
  1668. \label Exceptional Situations:\None.
  1669. \label See Also::
  1670. \funref{aref},
  1671. \funref{sbit},
  1672. \funref{schar},
  1673. \funref{vector},
  1674. \issue{CONSTANT-MODIFICATION:DISALLOW}
  1675. {\secref\ConstantModification}
  1676. \endissue{CONSTANT-MODIFICATION:DISALLOW}
  1677. \label Notes::
  1678. %% 17.2.0 8
  1679. \funref{svref} is identical to \funref{aref}
  1680. except that it requires its first argument to be a \term{simple vector}.
  1681. \code
  1682. (svref \param{v} \param{i}) \EQ (aref (the simple-vector \param{v}) \param{i})
  1683. \endcode
  1684. \endcom
  1685. %%% ========== VECTOR
  1686. \begincom{vector}\ftype{Function}
  1687. \label Syntax::
  1688. \DefunWithValues vector {{\rest} objects} {vector}
  1689. \label Arguments and Values::
  1690. \param{object}---an \term{object}.
  1691. \param{vector}---a \term{vector} of \term{type} \f{(vector t {\tt *})}.
  1692. \label Description::
  1693. %% 17.1.0 21
  1694. Creates a \term{fresh} \term{simple general vector} whose size
  1695. corresponds to the number of \param{objects}.
  1696. The \term{vector} is initialized to contain the \param{objects}.
  1697. \label Examples::
  1698. \code
  1699. (arrayp (setq v (vector 1 2 'sirens))) \EV \term{true}
  1700. (vectorp v) \EV \term{true}
  1701. (simple-vector-p v) \EV \term{true}
  1702. (length v) \EV 3
  1703. \endcode
  1704. \label Side Effects:\None.
  1705. \label Affected By:\None.
  1706. \label Exceptional Situations:\None!
  1707. \label See Also::
  1708. \funref{make-array}
  1709. \label Notes::
  1710. \funref{vector} is analogous to \funref{list}.
  1711. \code
  1712. (vector a\ssso a\ssst ... a\sssn)
  1713. \EQ (make-array (list \i{n}) :element-type t
  1714. :initial-contents
  1715. (list a\ssso a\ssst ... a\sssn))
  1716. \endcode
  1717. \endcom
  1718. %%% ========== VECTOR-POP
  1719. \begincom{vector-pop}\ftype{Function}
  1720. \label Syntax::
  1721. \DefunWithValues vector-pop {vector} {element}
  1722. \label Arguments and Values::
  1723. \param{vector}---a \term{vector} with a \term{fill pointer}.
  1724. \param{element}---an \term{object}.
  1725. \label Description::
  1726. %% 17.5.0 10
  1727. Decreases the \term{fill pointer} of \param{vector} by one,
  1728. and retrieves the \term{element} of \param{vector} that is
  1729. designated by the new \term{fill pointer}.
  1730. \label Examples::
  1731. \code
  1732. (vector-push (setq fable (list 'fable))
  1733. (setq fa (make-array 8
  1734. :fill-pointer 2
  1735. :initial-element 'sisyphus))) \EV 2
  1736. (fill-pointer fa) \EV 3
  1737. (eq (vector-pop fa) fable) \EV \term{true}
  1738. (vector-pop fa) \EV SISYPHUS
  1739. (fill-pointer fa) \EV 1
  1740. \endcode
  1741. \label Side Effects::
  1742. The \term{fill pointer} is decreased by one.
  1743. \label Affected By::
  1744. The value of the \term{fill pointer}.
  1745. \label Exceptional Situations::
  1746. An error \oftype{type-error} is signaled if \param{vector} does not have a \term{fill pointer}.
  1747. If the \term{fill pointer} is zero, \funref{vector-pop} signals an error \oftype{error}.
  1748. \label See Also::
  1749. \funref{vector-push}, \funref{vector-push-extend}, \funref{fill-pointer}
  1750. \label Notes:\None.
  1751. \endcom
  1752. %%% ========== VECTOR-PUSH
  1753. %%% ========== VECTOR-PUSH-EXTEND
  1754. \begincom{vector-push, vector-push-extend}\ftype{Function}
  1755. \label Syntax::
  1756. \DefunWithValues vector-push {new-element vector} {new-index-p}
  1757. \DefunWithValues vector-push-extend {new-element vector {\opt} extension} {new-index}
  1758. \label Arguments and Values::
  1759. \param{new-element}---an \term{object}.
  1760. \param{vector}---a \term{vector} with a \term{fill pointer}.
  1761. \param{extension}---a positive \term{integer}.
  1762. \Default{\term{implementation-dependent}}
  1763. \param{new-index-p}---a \term{valid array index} for \param{vector}, or \nil.
  1764. \param{new-index}---a \term{valid array index} for \param{vector}.
  1765. \label Description::
  1766. %% 17.5.0 8
  1767. \funref{vector-push} and \funref{vector-push-extend} store
  1768. \param{new-element} in \param{vector}.
  1769. \funref{vector-push} attempts to store
  1770. \param{new-element}
  1771. in the element of \param{vector} designated by the \term{fill pointer},
  1772. and to increase the \term{fill pointer} by one. If the
  1773. \f{(>= (fill-pointer \param{vector}) (array-dimension \param{vector} 0))},
  1774. neither \param{vector} nor its \term{fill pointer} are affected.
  1775. Otherwise, the store and increment take
  1776. place and \funref{vector-push}
  1777. returns the former value of the \term{fill pointer}
  1778. which is one less than the one it leaves in \param{vector}.
  1779. %% 17.5.0 9
  1780. \funref{vector-push-extend} is just like \funref{vector-push} except
  1781. that if the \term{fill pointer} gets too large, \param{vector} is extended using
  1782. \funref{adjust-array} so that it can contain more elements.
  1783. \param{Extension}
  1784. is the minimum number of elements to be added to \param{vector} if it
  1785. must be extended.
  1786. \funref{vector-push} and
  1787. \funref{vector-push-extend} return the index of \param{new-element} in \param{vector}.
  1788. If \f{(>= (fill-pointer \param{vector}) (array-dimension \param{vector} 0))},
  1789. \funref{vector-push} returns \nil.
  1790. \label Examples::
  1791. \code
  1792. (vector-push (setq fable (list 'fable))
  1793. (setq fa (make-array 8
  1794. :fill-pointer 2
  1795. :initial-element 'first-one))) \EV 2
  1796. (fill-pointer fa) \EV 3
  1797. (eq (aref fa 2) fable) \EV \term{true}
  1798. (vector-push-extend #\\X
  1799. (setq aa
  1800. (make-array 5
  1801. :element-type 'character
  1802. :adjustable t
  1803. :fill-pointer 3))) \EV 3
  1804. (fill-pointer aa) \EV 4
  1805. (vector-push-extend #\\Y aa 4) \EV 4
  1806. (array-total-size aa) \EV at least 5
  1807. (vector-push-extend #\\Z aa 4) \EV 5
  1808. (array-total-size aa) \EV 9 ;(or more)
  1809. \endcode
  1810. \label Affected By::
  1811. The value of the \term{fill pointer}.
  1812. How \param{vector} was created.
  1813. \label Exceptional Situations::
  1814. An error \oftype{error} is signaled by \funref{vector-push-extend}
  1815. if it tries to extend \param{vector} and \param{vector} is not \term{actually adjustable}.
  1816. An error \oftype{error} is signaled if \param{vector} does not
  1817. have a \term{fill pointer}.
  1818. \label See Also::
  1819. \funref{adjustable-array-p}, \funref{fill-pointer}, \funref{vector-pop}
  1820. \label Notes:\None.
  1821. \endcom
  1822. %%% ========== VECTORP
  1823. \begincom{vectorp}\ftype{Function}
  1824. \label Syntax::
  1825. \DefunWithValues vectorp {object} {generalized-boolean}
  1826. \label Arguments and Values::
  1827. \param{object}---an \term{object}.
  1828. \param{generalized-boolean}---a \term{generalized boolean}.
  1829. \label Description::
  1830. %% 6.2.2 20
  1831. \TypePredicate{object}{vector}
  1832. \label Examples::
  1833. \code
  1834. (vectorp "aaaaaa") \EV \term{true}
  1835. (vectorp (make-array 6 :fill-pointer t)) \EV \term{true}
  1836. (vectorp (make-array '(2 3 4))) \EV \term{false}
  1837. (vectorp #*11) \EV \term{true}
  1838. (vectorp #b11) \EV \term{false}
  1839. \endcode
  1840. \label Side Effects:\None.
  1841. \label Affected By:\None.
  1842. \label Exceptional Situations:\None!
  1843. \label See Also:\None.
  1844. \label Notes::
  1845. \code
  1846. (vectorp \param{object}) \EQ (typep \param{object} 'vector)
  1847. \endcode
  1848. \endcom
  1849. %-------------------- Bit Vectors --------------------
  1850. %%% ========== BIT
  1851. %%% ========== SBIT
  1852. \begincom{bit, sbit}\ftype{Accessor}
  1853. \label Syntax::
  1854. \DefunMultiWithValues {bit-array {\rest} subscripts} {bit}
  1855. {\entry{bit}
  1856. \entry{sbit}}
  1857. \DefsetfMulti {bit-array {\rest} subscripts} {new-bit}
  1858. {\entry{bit}
  1859. \entry{sbit}}
  1860. \label Arguments and Values::
  1861. \param{bit-array}---for \funref{bit}, a \term{bit array};
  1862. for \funref{sbit}, a \term{simple bit array}.
  1863. \param{subscripts}---a \term{list} of \term{valid array indices}
  1864. for the \param{bit-array}.
  1865. \param{bit}---a \term{bit}.
  1866. \label Description::
  1867. %% 17.4.0 3
  1868. %% 17.4.0 4
  1869. \funref{bit} and \funref{sbit} \term{access} the \param{bit-array}
  1870. \term{element} specified by \param{subscripts}.
  1871. %!!! Is this necessary to say? How is it said elsewhere?
  1872. These \term{functions} ignore the \term{fill pointer} when \term{accessing} \term{elements}.
  1873. %% This is implied by "access" above.
  1874. % %% 17.4.0 6
  1875. % \macref{setf} can be used with \funref{bit} or \funref{sbit} to destructively
  1876. % replace a \term{bit array} \term{element} with a new value.
  1877. \label Examples::
  1878. \code
  1879. (bit (setq ba (make-array 8
  1880. :element-type 'bit
  1881. :initial-element 1))
  1882. 3) \EV 1
  1883. (setf (bit ba 3) 0) \EV 0
  1884. (bit ba 3) \EV 0
  1885. (sbit ba 5) \EV 1
  1886. (setf (sbit ba 5) 1) \EV 1
  1887. (sbit ba 5) \EV 1
  1888. \endcode
  1889. \label Affected By:\None.
  1890. \label Exceptional Situations:\None.
  1891. \label See Also::
  1892. \funref{aref},
  1893. \issue{CONSTANT-MODIFICATION:DISALLOW}
  1894. {\secref\ConstantModification}
  1895. \endissue{CONSTANT-MODIFICATION:DISALLOW}
  1896. \label Notes::
  1897. %% 17.4.0 7
  1898. \funref{bit} and \funref{sbit} are like \funref{aref}
  1899. except that they require \param{arrays} to be
  1900. a \term{bit array} and a \term{simple bit array}, respectively.
  1901. %% 17.4.0 5
  1902. \funref{bit} and \funref{sbit}, unlike \funref{char} and \funref{schar},
  1903. allow the first argument to be an \term{array} of any \term{rank}.
  1904. \endcom
  1905. %%% ========== BIT-AND
  1906. %%% ========== BIT-ANDC1
  1907. %%% ========== BIT-ANDC2
  1908. %%% ========== BIT-EQV
  1909. %%% ========== BIT-IOR
  1910. %%% ========== BIT-NAND
  1911. %%% ========== BIT-NOR
  1912. %%% ========== BIT-NOT
  1913. %%% ========== BIT-ORC1
  1914. %%% ========== BIT-ORC2
  1915. %%% ========== BIT-XOR
  1916. \begincom{bit-and, bit-andc1, bit-andc2, bit-eqv,
  1917. bit-ior, bit-nand, bit-nor, bit-not, bit-orc1, bit-orc2, bit-xor}\ftype{Function}
  1918. \label Syntax::
  1919. \DefunMultiWithValues {bit-array1 bit-array2 {\opt} opt-arg} {resulting-bit-array}
  1920. {\entry{bit-and}
  1921. \entry{bit-andc1}
  1922. \entry{bit-andc2}
  1923. \entry{bit-eqv}
  1924. \entry{bit-ior}
  1925. \entry{bit-nand}
  1926. \entry{bit-nor}
  1927. \entry{bit-orc1}
  1928. \entry{bit-orc2}
  1929. \entry{bit-xor}}
  1930. \DefunWithValues bit-not {bit-array {\opt} opt-arg} {resulting-bit-array}
  1931. \label Arguments and Values::
  1932. \param{bit-array}, \param{bit-array1}, \param{bit-array2}---a \term{bit array}.
  1933. \param{Opt-arg}---a \term{bit array}, or \t, or \nil.
  1934. \Default{\nil}
  1935. %!!! This needs work. -kmp 24-May-91
  1936. \param{Bit-array}, \param{bit-array1}, \param{bit-array2}, and \param{opt-arg}
  1937. (if an \term{array}) must all be of the same \term{rank} and \term{dimensions}.
  1938. \param{resulting-bit-array}---a \term{bit array}.
  1939. \label Description::
  1940. %% 17.4.0 8
  1941. These functions perform
  1942. bit-wise logical operations on \param{bit-array1} and \param{bit-array2}
  1943. and return an \term{array}
  1944. of matching \term{rank} and \term{dimensions},
  1945. such that any given bit of the result
  1946. is produced by operating on corresponding bits from each of the arguments.
  1947. %% 17.4.0 11
  1948. In the case of \funref{bit-not}, an \term{array}
  1949. of \term{rank} and \term{dimensions} matching \param{bit-array}
  1950. is returned that contains a copy of \param{bit-array}
  1951. with all the bits inverted.
  1952. %% 17.4.0 9
  1953. %% 17.4.0 12
  1954. If \param{opt-arg} is of type \f{(array bit)} the contents of the
  1955. result are destructively placed into \param{opt-arg}.
  1956. If \param{opt-arg} is the symbol \t,
  1957. \param{bit-array} or \param{bit-array1} is replaced with the result;
  1958. if \param{opt-arg} is \nil\ or omitted, a new \term{array} is created
  1959. to contain the result.
  1960. %% 17.4.0 10
  1961. \Thenextfigure\ indicates the logical operation
  1962. performed by each of the \term{functions}.
  1963. \boxfig
  1964. {\dimen0=2pc
  1965. \tabskip 2\dimen0
  1966. \halign to \hsize {#\hfil\tabskip \dimen0&#\hfil\tabskip 0pt plus 1fil\cr
  1967. \noalign{\vskip -9pt}
  1968. {\bf Function}&{\bf Operation}\cr
  1969. \noalign{\vskip 2pt\hrule\vskip 2pt}
  1970. \cr
  1971. \funref{bit-and}&and\cr
  1972. \funref{bit-eqv}&equivalence (exclusive nor)\cr
  1973. \funref{bit-not}&complement\cr
  1974. \funref{bit-ior}&inclusive or\cr
  1975. \funref{bit-xor}&exclusive or\cr
  1976. \funref{bit-nand}&complement of \param{bit-array1} and \param{bit-array2}\cr
  1977. \funref{bit-nor}&complement of \param{bit-array1} or \param{bit-array2}\cr
  1978. \funref{bit-andc1}&and complement of \param{bit-array1} with \param{bit-array2}\cr
  1979. \funref{bit-andc2}&and \param{bit-array1} with complement of \param{bit-array2}\cr
  1980. \funref{bit-orc1}&or complement of \param{bit-array1} with \param{bit-array2}\cr
  1981. \funref{bit-orc2}&or \param{bit-array1} with complement of \param{bit-array2}\cr
  1982. \noalign{\vskip -9pt}
  1983. \caption{Bit-wise Logical Operations on Bit Arrays}\cr
  1984. }}
  1985. \endfig
  1986. \label Examples::
  1987. \code
  1988. (bit-and (setq ba #*11101010) #*01101011) \EV #*01101010
  1989. (bit-and #*1100 #*1010) \EV #*1000
  1990. (bit-andc1 #*1100 #*1010) \EV #*0010
  1991. (setq rba (bit-andc2 ba #*00110011 t)) \EV #*11001000
  1992. (eq rba ba) \EV \term{true}
  1993. (bit-not (setq ba #*11101010)) \EV #*00010101
  1994. (setq rba (bit-not ba
  1995. (setq tba (make-array 8
  1996. :element-type 'bit))))
  1997. \EV #*00010101
  1998. (equal rba tba) \EV \term{true}
  1999. (bit-xor #*1100 #*1010) \EV #*0110
  2000. \endcode
  2001. \label Affected By:\None.
  2002. \label Exceptional Situations:\None.
  2003. \label See Also::
  2004. \funref{lognot}, \funref{logand}
  2005. \label Notes:\None.
  2006. \endcom
  2007. %%% ========== BIT-VECTOR-P
  2008. \begincom{bit-vector-p}\ftype{Function}
  2009. \label Syntax::
  2010. \DefunWithValues bit-vector-p {object} {generalized-boolean}
  2011. \label Arguments and Values::
  2012. \param{object}---an \term{object}.
  2013. \param{generalized-boolean}---a \term{generalized boolean}.
  2014. \label Description::
  2015. %% 6.2.2 19
  2016. \TypePredicate{object}{bit-vector}
  2017. \label Examples::
  2018. \code
  2019. (bit-vector-p (make-array 6
  2020. :element-type 'bit
  2021. :fill-pointer t)) \EV \term{true}
  2022. (bit-vector-p #*) \EV \term{true}
  2023. (bit-vector-p (make-array 6)) \EV \term{false}
  2024. \endcode
  2025. \label Affected By:\None.
  2026. \label Exceptional Situations:\None!
  2027. \label See Also::
  2028. \funref{typep}
  2029. \label Notes::
  2030. \code
  2031. (bit-vector-p \param{object}) \EQ (typep \param{object} 'bit-vector)
  2032. \endcode
  2033. \endcom
  2034. %%% ========== SIMPLE-BIT-VECTOR-P
  2035. \begincom{simple-bit-vector-p}\ftype{Function}
  2036. \label Syntax::
  2037. \DefunWithValues simple-bit-vector-p {object} {generalized-boolean}
  2038. \label Arguments and Values::
  2039. \param{object}---an \term{object}.
  2040. \param{generalized-boolean}---a \term{generalized boolean}.
  2041. \label Description::
  2042. %% 6.2.2 23
  2043. \TypePredicate{object}{simple-bit-vector}
  2044. \label Examples::
  2045. \code
  2046. (simple-bit-vector-p (make-array 6)) \EV \term{false}
  2047. (simple-bit-vector-p #*) \EV \term{true}
  2048. \endcode
  2049. \label Side Effects:\None.
  2050. \label Affected By:\None.
  2051. \label Exceptional Situations:\None!
  2052. \label See Also::
  2053. \funref{simple-vector-p}
  2054. \label Notes::
  2055. \code
  2056. (simple-bit-vector-p \param{object}) \EQ (typep \param{object} 'simple-bit-vector)
  2057. \endcode
  2058. \endcom