dict-types.tex 64 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978
  1. % -*- Mode: TeX -*-
  2. %%% ========== NIL
  3. \begincom{nil}\ftype{Type}
  4. \label Supertypes::
  5. all \term{types}
  6. \label Description::
  7. \Thetype{nil} contains no \term{objects} and so is also
  8. called the \term{empty type}.
  9. %% 2.15.0 5
  10. \Thetype{nil} is a \term{subtype} of every \term{type}.
  11. No \term{object} is \oftype{nil}.
  12. \label Notes::
  13. The \term{type} containing the \term{object} \nil\ is \thetype{null},
  14. not \thetype{nil}.
  15. \endcom%{nil}\ftype{Type}
  16. %%% ========== BOOLEAN
  17. \begincom{boolean}\ftype{Type}
  18. \label Supertypes::
  19. \typeref{boolean},
  20. \typeref{symbol},
  21. \typeref{t}
  22. \label Description::
  23. \Thetype{boolean} contains the \term{symbols} \misc{t} and \misc{nil},
  24. which represent true and false, respectively.
  25. \label See Also::
  26. \misc{t} (\term{constant variable}),
  27. \misc{nil} (\term{constant variable}),
  28. \specref{if},
  29. \funref{not},
  30. \funref{complement}
  31. \label Notes::
  32. Conditional operations, such as \specref{if},
  33. permit the use of \term{generalized booleans},
  34. not just \term{booleans};
  35. any \term{non-nil} value,
  36. not just \misc{t},
  37. counts as true for a \term{generalized boolean}.
  38. However, as a matter of convention,
  39. the \term{symbol} \misc{t} is considered the canonical value to use
  40. even for a \term{generalized boolean} when no better choice presents itself.
  41. \endcom%{boolean}\ftype{Type}
  42. %Number and its subtypes moved to dict-numbers.
  43. %Character and its subtypes moved to dict-characters.
  44. %System Class SYMBOL moved to dict-symbols.
  45. %Type KEYWORD moved to dict-symbols.
  46. %Type SEQUENCE moved to dict-sequence.
  47. %Type LIST, NULL, CONS, ATOM, ... moved to dict-conses.
  48. %Types ARRAY, STRING, etc. to dict-strings.
  49. %% new definition here?
  50. %%% ========== FUNCTION
  51. \begincom{function}\ftype{System Class}
  52. \issue{FUNCTION-TYPE:X3J13-MARCH-88}
  53. \label Class Precedence List::
  54. \typeref{function},
  55. \typeref{t}
  56. \label Description::
  57. A \term{function} is an \term{object} that represents code
  58. to be executed when an appropriate number of arguments is supplied.
  59. %Removed per symbolics comments:
  60. % A \term{function} can be supplied as an
  61. %argument without error to \funref{funcall} or \funref{apply}.
  62. A \term{function} is produced by
  63. \thespecform{function},
  64. \thefunction{coerce},
  65. \issue{SYNTACTIC-ENVIRONMENT-ACCESS:RETRACTED-MAR91}
  66. %the \thefunction{enclose},
  67. \endissue{SYNTACTIC-ENVIRONMENT-ACCESS:RETRACTED-MAR91}
  68. or
  69. \thefunction{compile}.
  70. A \term{function} can be directly invoked by using it as the first argument to
  71. \funref{funcall}, \funref{apply}, or \specref{multiple-value-call}.
  72. %!!! Barrett says this syntax is confused.
  73. % Issues: &allow-other-keys, &key in value-typespec, &key mis-formatted where it already is.
  74. \label Compound Type Specifier Kind::
  75. Specializing.
  76. \label Compound Type Specifier Syntax::
  77. %% 4.5.0 12
  78. \Deftype{function}{\ttbrac{arg-typespec \brac{value-typespec}}}
  79. \auxbnf{arg-typespec}{\lparen\starparam{typespec} \CR
  80. \ \ttbrac{{\opt} \starparam{typespec}} \CR
  81. \ \ttbrac{{\rest} \param{typespec}} \CR
  82. \ \ttbrac{{\key} \starparen{keyword typespec}}\rparen}
  83. \label Compound Type Specifier Arguments::
  84. \param{typespec}---a \term{type specifier}.
  85. \param{value-typespec}---a \term{type specifier}.
  86. \label Compound Type Specifier Description::
  87. \editornote{KMP: Isn't there some context info about ftype declarations to be merged here?}
  88. \editornote{KMP: This could still use some cleaning up.}%!!!
  89. \editornote{Sandra: Still need clarification about what happens if the
  90. number of arguments doesn't match the FUNCTION type declaration.}
  91. The list form of the \typeref{function} \term{type-specifier}
  92. can be used only for declaration and not for discrimination.
  93. Every element of this \term{type} is
  94. % I think the ``at least'' is confusing. --sjl 7 Mar 92
  95. % a \term{function} that accepts arguments at least of the
  96. a \term{function} that accepts arguments of the
  97. types
  98. specified by the \param{argj-types} and returns values that are
  99. members of the \term{types} specified by \param{value-type}. The
  100. \keyref{optional}, \keyref{rest}, \keyref{key},
  101. \issue{FUNCTION-TYPE-KEY-NAME:SPECIFY-KEYWORD}
  102. and \keyref{allow-other-keys}
  103. \endissue{FUNCTION-TYPE-KEY-NAME:SPECIFY-KEYWORD}
  104. markers can appear in the list of argument types.
  105. \issue{FUNCTION-TYPE-REST-LIST-ELEMENT:USE-ACTUAL-ARGUMENT-TYPE}
  106. The \term{type specifier} provided
  107. with \keyref{rest} is the \term{type}
  108. of each actual argument, not the \term{type} of the
  109. corresponding variable.
  110. \endissue{FUNCTION-TYPE-REST-LIST-ELEMENT:USE-ACTUAL-ARGUMENT-TYPE}
  111. \issue{FUNCTION-TYPE-KEY-NAME:SPECIFY-KEYWORD}
  112. The \keyref{key} parameters
  113. should be supplied as lists of the form {\tt (\param{keyword} \param{type})}.
  114. The \param{keyword} must be a valid keyword-name symbol
  115. as must be supplied in the actual arguments of a
  116. call.
  117. \issue{KEYWORD-ARGUMENT-NAME-PACKAGE:ANY}
  118. This is usually a \term{symbol} in \thepackage{keyword} but can be any \term{symbol}.
  119. \endissue{KEYWORD-ARGUMENT-NAME-PACKAGE:ANY}
  120. % tweaked to be less wordy --sjl 7 Mar 92
  121. %The \keyref{allow-other-keys} declarations are interpreted as follows:
  122. %when \keyref{key} is given in a
  123. %\declref{function} \term{type specifier} \term{lambda list},
  124. %it is safe to assume that the \term{keyword parameters} given
  125. When \keyref{key} is given in a
  126. \declref{function} \term{type specifier} \term{lambda list},
  127. the \term{keyword parameters} given
  128. are exhaustive unless \keyref{allow-other-keys} is also present.
  129. \keyref{allow-other-keys} is an indication
  130. that other keyword arguments might actually be
  131. supplied and, if supplied, can be used.
  132. For example,
  133. the \term{type} of \thefunction{make-list} could be declared as follows:
  134. \code
  135. (function ((integer 0) &key (:initial-element t)) list)
  136. \endcode
  137. \endissue{FUNCTION-TYPE-KEY-NAME:SPECIFY-KEYWORD}
  138. The \param{value-type} can be a \declref{values}
  139. \term{type specifier} in order to indicate the
  140. \term{types} of \term{multiple values}.
  141. \issue{FUNCTION-TYPE-ARGUMENT-TYPE-SEMANTICS:RESTRICTIVE}
  142. %{The following will be deleted:}
  143. %
  144. %
  145. %%% 4.5.0 13
  146. %For example, \thefunction{cons} is of type \f{(function (t t) cons)},
  147. %because it can accept any two arguments and always returns a \term{cons}.
  148. %%%see FUNCTION-TYPE-ARGUMENT-TYPE-SEMANTICS; cons isn't of the following type.
  149. %\funref{cons} is also of type {\tt (function (float string) list)},
  150. %because it can
  151. %accept a \term{float}
  152. %and a \term{string} (among other things), and its
  153. %result is always \oftype{list}
  154. %(in fact a \term{cons} is never \term{null},
  155. %but that does not matter for this type declaration).
  156. %\funref{truncate} is of type
  157. %{\tt (function (number number) (values number number))},
  158. %as well as of type
  159. %{\tt (function (integer (mod 8)) integer)}.
  160. %
  161. %{End of deletion.}
  162. Consider a declaration of the following form:
  163. \code
  164. (ftype (function (arg0-type arg1-type ...) val-type) f))
  165. \endcode
  166. Any \term{form}
  167. {\tt (f arg0 arg1 ...)}
  168. within the scope of
  169. that declaration is equivalent to the following:
  170. \code
  171. (the val-type (f (the arg0-type arg0) (the arg1-type arg1) ...))
  172. \endcode
  173. That is, the consequences are undefined if any of the arguments are
  174. not of the specified \term{types} or the result is not of the
  175. specified \term{type}. In particular, if any argument is not of the
  176. correct \term{type}, the result is not guaranteed to be of the
  177. specified \term{type}.
  178. Thus, an \declref{ftype} declaration for a \term{function}
  179. describes \term{calls} to the \term{function}, not the actual definition
  180. of the \term{function}.
  181. Consider a declaration of the following form:
  182. \code
  183. (type (function (arg0-type arg1-type ...) val-type) fn-valued-variable)
  184. \endcode
  185. This declaration has the interpretation that, within the scope of the
  186. declaration, the consequences are unspecified if the value of {\tt
  187. fn-valued-variable} is called with arguments not of the specified
  188. \term{types}; the value resulting from a valid call will be of type
  189. {\tt val-type}.
  190. As with variable type declarations, nested declarations
  191. imply intersections of \term{types}, as follows:
  192. \beginlist
  193. \itemitem{\bull}
  194. Consider the following two
  195. declarations of \declref{ftype}:
  196. \code
  197. (ftype (function (arg0-type1 arg1-type1 ...) val-type1) f))
  198. \endcode
  199. and
  200. \code
  201. (ftype (function (arg0-type2 arg1-type2 ...) val-type2) f))
  202. \endcode
  203. If both these declarations are in effect,
  204. then within the shared scope of the declarations, calls to {\tt f} can be
  205. treated as if {\tt f} were declared as follows:
  206. \code
  207. (ftype (function ((and arg0-type1 arg0-type2) (and arg1-type1 arg1-type2 ...) ...)
  208. (and val-type1 val-type2))
  209. f))
  210. \endcode
  211. %!!! Barmar: what does this mean?
  212. % KMP: This is ill-worded and out of place.
  213. It is permitted to ignore one or all of the \declref{ftype} declarations in force.
  214. \itemitem{\bull}
  215. If two (or more) type declarations are in effect for a variable, and
  216. they are both {\tt function} declarations, the declarations combine similarly.
  217. \endlist
  218. \endissue{FUNCTION-TYPE-ARGUMENT-TYPE-SEMANTICS:RESTRICTIVE}
  219. \endissue{FUNCTION-TYPE:X3J13-MARCH-88}
  220. \endcom%{function}\ftype{System Class}
  221. %%% ========== COMPILED-FUNCTION
  222. \begincom{compiled-function}\ftype{Type}
  223. \issue{FUNCTION-TYPE:X3J13-MARCH-88}
  224. \label Supertypes::
  225. \typeref{compiled-function},
  226. \typeref{function},
  227. \typeref{t}
  228. \label Description::
  229. \issue{COMPILED-FUNCTION-REQUIREMENTS:TIGHTEN}
  230. Any \term{function} may be considered by an \term{implementation} to be a
  231. a \term{compiled function} if it contains no references to \term{macros} that
  232. must be expanded at run time, and it contains no unresolved references
  233. to \term{load time values}. \Seesection\CompilationSemantics.
  234. \endissue{COMPILED-FUNCTION-REQUIREMENTS:TIGHTEN}
  235. %% 2.13.0 2
  236. \term{Functions} whose definitions appear lexically within a
  237. \term{file} that has been \term{compiled} with \funref{compile-file} and then
  238. \term{loaded} with \funref{load} are \oftype{compiled-function}.
  239. \issue{COMPILED-FUNCTION-REQUIREMENTS:TIGHTEN}
  240. \term{Functions} produced by the \funref{compile} function
  241. are \oftype{compiled-function}.
  242. \endissue{COMPILED-FUNCTION-REQUIREMENTS:TIGHTEN}
  243. Other \term{functions} might also be \oftype{compiled-function}.
  244. %but \funref{compile} does not necessarily produce a \term{compiled function}.
  245. \endissue{FUNCTION-TYPE:X3J13-MARCH-88}
  246. \endcom%{compiled-function}\ftype{Type}
  247. %%% ========== GENERIC-FUNCTION
  248. \begincom{generic-function}\ftype{System Class}
  249. \issue{JUN90-TRIVIAL-ISSUES:9}
  250. \label Class Precedence List::
  251. \typeref{generic-function},
  252. \typeref{function},
  253. \typeref{t}
  254. \endissue{JUN90-TRIVIAL-ISSUES:9}
  255. \label Description::
  256. A \newterm{generic function} is a \term{function} whose behavior
  257. depends on the \term{classes} or identities of the \term{arguments}
  258. supplied to it. A generic function object contains a set of
  259. \term{methods}, a \term{lambda list}, a \term{method combination} \term{type},
  260. and other information. The \term{methods}
  261. define the class-specific behavior and operations of the \term{generic function};
  262. a \term{method} is said to \term{specialize} a \term{generic function}.
  263. When invoked, a \term{generic function} executes a subset of its
  264. \term{methods} based on the \term{classes} or identities of its \term{arguments}.
  265. A \term{generic function} can be used in the same ways that an
  266. ordinary \term{function} can be used; specifically, a \term{generic function} can
  267. be used as an argument to \funref{funcall} and \funref{apply},
  268. and can be given a global or a local name.
  269. \endcom%{generic-function}\ftype{System Class}
  270. %%% ========== STANDARD-GENERIC-FUNCTION
  271. \begincom{standard-generic-function}\ftype{System Class}
  272. \label Class Precedence List::
  273. \typeref{standard-generic-function},
  274. \typeref{generic-function},
  275. \typeref{function},
  276. \typeref{t}
  277. \label Description::
  278. \Theclass{standard-generic-function} is the default \term{class} of
  279. \term{generic functions} \term{established} by
  280. \macref{defmethod},
  281. \funref{ensure-generic-function},
  282. \macref{defgeneric},
  283. \issue{GENERIC-FLET-POORLY-DESIGNED:DELETE}
  284. % \macref{generic-function},
  285. % \specref{generic-flet},
  286. % \specref{generic-labels},
  287. \endissue{GENERIC-FLET-POORLY-DESIGNED:DELETE}
  288. \issue{WITH-ADDED-METHODS:DELETE}
  289. %\specref{with-added-methods},
  290. \endissue{WITH-ADDED-METHODS:DELETE}%
  291. and
  292. \macref{defclass} \term{forms}.
  293. \endcom%{standard-generic-function}\ftype{System Class}
  294. %random-state moved to dict-numbers
  295. %conditions moved to dict-conditions, some perhaps to move again
  296. %%% ========== CLASS
  297. \begincom{class}\ftype{System Class}
  298. \issue{JUN90-TRIVIAL-ISSUES:9}
  299. \label Class Precedence List::
  300. \typeref{class},
  301. \issue{TYPE-OF-AND-PREDEFINED-CLASSES:UNIFY-AND-EXTEND}
  302. \typeref{standard-object},
  303. \endissue{TYPE-OF-AND-PREDEFINED-CLASSES:UNIFY-AND-EXTEND}
  304. \typeref{t}
  305. \endissue{JUN90-TRIVIAL-ISSUES:9}
  306. \label Description::
  307. %!!! Barrett: Since none of this can be accessed portably,
  308. % why specifically mention any of it?
  309. \Thetype{class} represents \term{objects} that determine the structure
  310. and behavior of their \term{instances}. Associated with an \term{object}
  311. \oftype{class} is information describing its place in the
  312. directed acyclic graph of \term{classes}, its \term{slots}, and its options.
  313. %% Barrett: No! This is a gross AMOPism.
  314. %and information about the \term{methods} that mention this \term{class} as a specializer.
  315. % I had a terrible time figuring out what these paragraphs were trying
  316. % to say until I realized what cleanup issue they were from. I've moved
  317. % this text to the discussion of built-in types in the classes concepts
  318. % section, where there is more context for it. --sjl 7 Mar 92
  319. %\issue{CONDITION-SLOTS:HIDDEN}
  320. %It is \term{implementation-dependent} whether \term{slots} are involved in the
  321. %operation of \term{functions} defined in this specification
  322. %on \term{instances} of \term{classes} defined in this specification,
  323. %except when \term{slots} are explicitly defined by this specification.
  324. %
  325. %If in a particular \term{implementation} a \term{class} defined in this specification
  326. %has \term{slots} that are not defined by this specfication, the names of these \term{slots}
  327. %must not be \term{external symbols} of \term{packages} defined in this specification nor
  328. %otherwise \term{accessible} in \thepackage{cl-user}.
  329. %\endissue{CONDITION-SLOTS:HIDDEN}
  330. \endcom%{class}\ftype{System Class}
  331. %%% ========== BUILT-IN-CLASS
  332. \begincom{built-in-class}\ftype{System Class}
  333. \label Class Precedence List::
  334. \typeref{built-in-class},
  335. \typeref{class},
  336. \issue{TYPE-OF-AND-PREDEFINED-CLASSES:UNIFY-AND-EXTEND}
  337. \typeref{standard-object},
  338. \endissue{TYPE-OF-AND-PREDEFINED-CLASSES:UNIFY-AND-EXTEND}
  339. \typeref{t}
  340. \label Description::
  341. A \term{built-in class} is a \term{class} whose \term{instances} have
  342. restricted capabilities or special representations.
  343. %!!! Barrett: The rest of this looks like a duplication of text a few pages back.
  344. Attempting to use
  345. \macref{defclass} to define \term{subclasses} of a \term{built-in class}
  346. signals an error \oftype{error}.
  347. Calling \funref{make-instance} to create an \term{instance}
  348. of a \term{built-in class} signals an error \oftype{error}.
  349. Calling \funref{slot-value} on an \term{instance} of a \term{built-in class}
  350. signals an error \oftype{error}. Redefining a \term{built-in class}
  351. or using \funref{change-class} to change the \term{class} of an \term{instance}
  352. to or from a \term{built-in class} signals an error \oftype{error}.
  353. However, \term{built-in classes} can be used as \term{parameter specializers}
  354. in \term{methods}.
  355. %!!! Barrett: Other ops also signal errors.
  356. % See SLOT-VALUE-METACLASSES
  357. %Any \term{class} that corresponds to a standard
  358. %\clisp\ type specified in \CLtL\
  359. %might be an instance of \typeref{built-in-class}.
  360. %The predefined Common Lisp \term{type specifiers} that are required to have
  361. %corresponding classes are listed in \figref\ClassTypeCorrespondence. It is implementation
  362. %dependent whether each of these classes is implemented as a built-in class.
  363. \endcom%{built-in-class}\ftype{System Class}
  364. %%% ========== STRUCTURE-CLASS
  365. \begincom{structure-class}\ftype{System Class}
  366. \label Class Precedence List::
  367. \typeref{structure-class},
  368. \typeref{class},
  369. \issue{TYPE-OF-AND-PREDEFINED-CLASSES:UNIFY-AND-EXTEND}
  370. \typeref{standard-object},
  371. \endissue{TYPE-OF-AND-PREDEFINED-CLASSES:UNIFY-AND-EXTEND}
  372. \typeref{t}
  373. \label Description::
  374. All \term{classes} defined by means of \macref{defstruct}
  375. are \instsofclass{structure-class}.
  376. \endcom%{structure-class}\ftype{System Class}
  377. %%% ========== STANDARD-CLASS
  378. \begincom{standard-class}\ftype{System Class}
  379. \label Class Precedence List::
  380. \typeref{standard-class},
  381. \typeref{class},
  382. \issue{TYPE-OF-AND-PREDEFINED-CLASSES:UNIFY-AND-EXTEND}
  383. \typeref{standard-object},
  384. \endissue{TYPE-OF-AND-PREDEFINED-CLASSES:UNIFY-AND-EXTEND}
  385. \typeref{t}
  386. \label Description::
  387. \Theclass{standard-class} is the default \term{class} of \term{classes}
  388. defined by \macref{defclass}.
  389. \endcom%{standard-class}\ftype{System Class}
  390. %%% ========== METHOD
  391. \begincom{method}\ftype{System Class}
  392. \issue{JUN90-TRIVIAL-ISSUES:9}
  393. \label Class Precedence List::
  394. \typeref{method},
  395. \typeref{t}
  396. \endissue{JUN90-TRIVIAL-ISSUES:9}
  397. \label Description::
  398. A \term{method} is an \term{object} that represents a modular part of the behavior
  399. of a \term{generic function}.
  400. A \term{method} contains \term{code} to implement the \term{method}'s
  401. behavior, a sequence of \term{parameter specializers} that specify when the
  402. given \term{method} is applicable, and a sequence of \term{qualifiers}
  403. that is used by the method combination facility to distinguish among
  404. \term{methods}. Each required parameter of each
  405. \term{method} has an associated \term{parameter specializer}, and the
  406. \term{method} will be invoked only on arguments that satisfy its
  407. \term{parameter specializers}.
  408. The method combination facility controls the selection of
  409. \term{methods}, the order in which they are run, and the values that are
  410. returned by the generic function. The \CLOS\ offers a default method
  411. combination type and provides a facility for declaring new types of
  412. method combination.
  413. \label See Also::
  414. {\secref\GFsAndMethods}
  415. \endcom%{method}\ftype{System Class}
  416. %%% ========== STANDARD-METHOD
  417. \begincom{standard-method}\ftype{System Class}
  418. \label Class Precedence List::
  419. \typeref{standard-method},
  420. \typeref{method},
  421. \issue{TYPE-OF-AND-PREDEFINED-CLASSES:UNIFY-AND-EXTEND}
  422. \typeref{standard-object},
  423. \endissue{TYPE-OF-AND-PREDEFINED-CLASSES:UNIFY-AND-EXTEND}
  424. \typeref{t}
  425. \label Description::
  426. \Theclass{standard-method} is the default \term{class} of
  427. \term{methods} defined by the
  428. \macref{defmethod} and
  429. \macref{defgeneric} \term{forms}.
  430. \issue{GENERIC-FLET-POORLY-DESIGNED:DELETE}
  431. % \macref{generic-function},
  432. \endissue{GENERIC-FLET-POORLY-DESIGNED:DELETE}
  433. \issue{WITH-ADDED-METHODS:DELETE}
  434. %\specref{with-added-methods},
  435. \endissue{WITH-ADDED-METHODS:DELETE}%
  436. % \specref{generic-flet},
  437. % and
  438. % \specref{generic-labels} \term{forms}.
  439. \endcom%{standard-method}\ftype{System Class}
  440. %%% ========== STRUCTURE-OBJECT
  441. \begincom{structure-object}\ftype{Class}
  442. \issue{JUN90-TRIVIAL-ISSUES:9}
  443. \label Class Precedence List::
  444. \typeref{structure-object},
  445. \typeref{t}
  446. \endissue{JUN90-TRIVIAL-ISSUES:9}
  447. \label Description::
  448. % \Theclass{structure-object} is a \term{superclass} of
  449. % every \term{class} that is defined by \macref{defstruct}.
  450. \Theclass{structure-object} is an \term{instance} of \typeref{structure-class}
  451. and is a \term{superclass} of every \term{class}
  452. that is an \term{instance} of \typeref{structure-class}
  453. except itself, and is a \term{superclass} of every \term{class}
  454. that is defined by \macref{defstruct}.
  455. \issue{DATA-TYPES-HIERARCHY-UNDERSPECIFIED}%
  456. %% Barrett: This is bogus. I think there is enough other text in the draft
  457. %% (the first bullet in ``Type Relationships'' plus the definition of
  458. %% \term{system class}) to cover the requirements specified by
  459. %% DATA-TYPES-HIERARCHY-UNDERSPECIFIED that this could simply be removed.
  460. % The following \term{type specifier} \term{symbols} do not name
  461. % \term{structure} \term{types} in any \term{implementation}:
  462. % \typeref{cons}, \typeref{symbol}, \typeref{array},
  463. % \typeref{number},
  464. % \typeref{character}, \typeref{hash-table},
  465. % \typeref{readtable}, \typeref{package}, \typeref{pathname},
  466. % \typeref{stream}, or
  467. % \typeref{random-state}.
  468. % It is \term{implementation-dependent}
  469. % whether other \term{standardized} \term{type specifiers} name structure types.
  470. \endissue{DATA-TYPES-HIERARCHY-UNDERSPECIFIED}
  471. \label See Also::
  472. \macref{defstruct},
  473. {\secref\SharpsignS},
  474. {\secref\PrintingStructures}
  475. \endcom%{structure-object}\ftype{Class}
  476. %%% ========== STANDARD-OBJECT
  477. \begincom{standard-object}\ftype{Class}
  478. \label Class Precedence List::
  479. \typeref{standard-object},
  480. \typeref{t}
  481. \label Description::
  482. \Theclass{standard-object} is an \term{instance} of \typeref{standard-class}
  483. and is a \term{superclass} of every \term{class} that is an \term{instance} of
  484. \typeref{standard-class} except itself.
  485. % and
  486. %\typeref{structure-class}.
  487. \endcom%{standard-object}\ftype{Class}
  488. %%% ========== METHOD-COMBINATION
  489. \begincom{method-combination}\ftype{System Class}
  490. \label Class Precedence List::
  491. \typeref{method-combination},
  492. \typeref{t}
  493. \label Description::
  494. Every \term{method combination} \term{object} is an
  495. \term{indirect instance} of the \term{class} \typeref{method-combination}.
  496. A \term{method combination} \term{object} represents the information about
  497. the \term{method combination} being used by a \term{generic function}.
  498. A \term{method combination} \term{object} contains information about
  499. both the type of \term{method combination} and the arguments being used
  500. with that \term{type}.
  501. \endcom%{method-combination}\ftype{System Class}
  502. %%% ========== T
  503. %% 2.0.0 6
  504. \begincom{t}\ftype{System Class}
  505. \label Class Precedence List::
  506. \typeref{t}
  507. \label Description::
  508. The set of all \term{objects}.
  509. %% 2.15.0 4
  510. \Thetype{t} is a \term{supertype} of every \term{type},
  511. including itself. Every \term{object} is \oftype{t}.
  512. \issue{COMMON-TYPE:REMOVE}
  513. % Reference to type COMMON removed, and moved to Appendix A.
  514. \endissue{COMMON-TYPE:REMOVE}
  515. \endcom%{t}\ftype{System Class}
  516. %%% ========== SATISFIES
  517. \begincom{satisfies}\ftype{Type Specifier}
  518. \label Compound Type Specifier Kind::
  519. Predicating.
  520. \label Compound Type Specifier Syntax::
  521. \Deftype{satisfies}{predicate-name}
  522. \label Compound Type Specifier Arguments::
  523. \param{predicate-name}---a \term{symbol}.
  524. \label Compound Type Specifier Description::
  525. %% 4.3.0 1
  526. %\itemitem
  527. %{\tt (satisfies \param{predicate-name})}
  528. This denotes the set of all \term{objects} that satisfy the
  529. \term{predicate} \param{predicate-name}, which must be a \term{symbol}
  530. whose global \term{function} definition is a one-argument
  531. predicate. A name is required for \param{predicate-name};
  532. \term{lambda expressions} are not allowed.
  533. For example, the \term{type specifier} {\tt (and integer (satisfies evenp))}
  534. denotes the set of all even integers.
  535. The form {\tt (typep \param{x} '(satisfies \param{p}))} is equivalent to
  536. {\tt (if (\param{p} \param{x}) t nil)}.
  537. % The call {\tt (typep x '(satisfies p))} results in applying
  538. % \f{p} to \f{x} and returning \f{t} if the result is \term{true} and \nil\ if the
  539. % result is \term{false}.
  540. %% 4.3.0 2
  541. %% I don't like the following example because it presupposes that standard-char-p is not
  542. % defined in terms of typep. -kmp 24-Oct-90
  543. % For example, \thetype{standard-char} could be defined as follows:
  544. %
  545. % \code
  546. % (deftype standard-char () '(and character (satisfies standard-char-p)))
  547. % \endcode
  548. \issue{TYPE-SPECIFIER-ABBREVIATION:X3J13-JUN90-GUESS}
  549. The argument is required.
  550. The \term{symbol} \misc{*} can be the argument, but it
  551. denotes itself (the \term{symbol} \misc{*}),
  552. and does not represent an unspecified value.
  553. The symbol \typeref{satisfies} is not valid as a \term{type specifier}.
  554. \endissue{TYPE-SPECIFIER-ABBREVIATION:X3J13-JUN90-GUESS}
  555. \endcom%{satisfies}\ftype{Type Specifier}
  556. %%% ========== MEMBER
  557. \begincom{member}\ftype{Type Specifier}
  558. \label Compound Type Specifier Kind::
  559. Combining.
  560. \label Compound Type Specifier Syntax::
  561. \Deftype{member}{\starparam{object}}
  562. \label Compound Type Specifier Arguments::
  563. \param{object}---an \term{object}.
  564. \label Compound Type Specifier Description::
  565. %% 4.4.0 3
  566. %\itemitem
  567. %{\tt (member \starparam{object})}
  568. %{\tt (member \param{object1} \param{object2} ...)}
  569. This denotes the set containing the named \param{objects}. An
  570. \term{object} is of this \term{type} if and only if it is \funref{eql}
  571. to one of the specified \param{objects}.
  572. \issue{TYPE-SPECIFIER-ABBREVIATION:X3J13-JUN90-GUESS}
  573. The \term{type specifiers} \f{(member)} and \nil\ are equivalent.
  574. \misc{*} can be among the \param{objects},
  575. but if so it denotes itself (the symbol \misc{*})
  576. and does not represent an unspecified value.
  577. The symbol \misc{member} is not valid as a \term{type specifier};
  578. and, specifically, it is not an abbreviation for either \f{(member)} or \f{(member *)}.
  579. \endissue{TYPE-SPECIFIER-ABBREVIATION:X3J13-JUN90-GUESS}
  580. \label See Also::
  581. \thetype{eql}
  582. \endcom%{member}\ftype{Type Specifier}
  583. %%% ========== NOT
  584. \begincom{not}\ftype{Type Specifier}
  585. \label Compound Type Specifier Kind::
  586. Combining.
  587. \label Compound Type Specifier Syntax::
  588. %% 4.4.0 4
  589. \Deftype{not}{typespec}
  590. \label Compound Type Specifier Arguments::
  591. \param{typespec}---a \term{type specifier}.
  592. \label Compound Type Specifier Description::
  593. This denotes the set of all \term{objects} that are not of the \term{type} \param{typespec}.
  594. \issue{TYPE-SPECIFIER-ABBREVIATION:X3J13-JUN90-GUESS}
  595. The argument is required, and cannot be \misc{*}.
  596. The symbol \typeref{not} is not valid as a \term{type specifier}.
  597. \endissue{TYPE-SPECIFIER-ABBREVIATION:X3J13-JUN90-GUESS}
  598. \endcom%{not}\ftype{Type Specifier}
  599. %%% ========== AND
  600. \begincom{and}\ftype{Type Specifier}
  601. \label Compound Type Specifier Kind::
  602. Combining.
  603. \label Compound Type Specifier Syntax::
  604. %% 4.4.0 5
  605. \Deftype{and}{\starparam{typespec}}
  606. \label Compound Type Specifier Arguments::
  607. \param{typespec}---a \term{type specifier}.
  608. \label Compound Type Specifier Description::
  609. This denotes the set of all \term{objects} of the \term{type}
  610. determined by the intersection of the \param{typespecs}.
  611. \issue{TYPE-SPECIFIER-ABBREVIATION:X3J13-JUN90-GUESS}
  612. \misc{*} is not permitted as an argument.
  613. The \term{type specifiers} \f{(and)} and \t\ are equivalent.
  614. The symbol \misc{and} is not valid as a \term{type specifier},
  615. and, specifically, it is not an abbreviation for \f{(and)}.
  616. \endissue{TYPE-SPECIFIER-ABBREVIATION:X3J13-JUN90-GUESS}
  617. \endcom%{and}\ftype{Type Specifier}
  618. %%% ========== OR
  619. \begincom{or}\ftype{Type Specifier}
  620. \label Compound Type Specifier Kind::
  621. Combining.
  622. \label Compound Type Specifier Syntax::
  623. %% 4.4.0 7
  624. \Deftype{or}{\starparam{typespec}}
  625. \label Compound Type Specifier Arguments::
  626. \param{typespec}---a \term{type specifier}.
  627. \label Compound Type Specifier Description::
  628. This denotes the set of all \term{objects} of the
  629. \term{type} determined by the union of the \param{typespecs}.
  630. For example, \thetype{list} by definition is the same as \f{(or null cons)}.
  631. Also, the value returned by \funref{position} is an \objectoftype{(or null (integer 0 *))};
  632. \ie either \nil\ or a non-negative \term{integer}.
  633. \issue{TYPE-SPECIFIER-ABBREVIATION:X3J13-JUN90-GUESS}
  634. \misc{*} is not permitted as an argument.
  635. The \term{type specifiers} \f{(or)} and \nil\ are equivalent.
  636. The symbol \typeref{or} is not valid as a \term{type specifier};
  637. and, specifically, it is not an abbreviation for \f{(or)}.
  638. \endissue{TYPE-SPECIFIER-ABBREVIATION:X3J13-JUN90-GUESS}
  639. \endcom%{or}\ftype{Type Specifier}
  640. %%% ========== VALUES
  641. \begincom{values}\ftype{Type Specifier}
  642. \label Compound Type Specifier Kind::
  643. Specializing.
  644. \label Compound Type Specifier Syntax::
  645. \Deftype{values}{\down{value-typespec}}
  646. \reviewer{Barmar: Missing \keyref{key}}%!!!
  647. \auxbnf{value-typespec}{\starparam{typespec}
  648. \ttbrac{{\opt} {\starparam{typespec}}}
  649. \ttbrac{{\rest} typespec}
  650. \ttbrac{\keyref{allow-other-keys}}}
  651. \label Compound Type Specifier Arguments::
  652. \param{typespec}---a \term{type specifier}.
  653. \label Compound Type Specifier Description::
  654. %% 4.5.0 14
  655. %\itemitem{\tt (values \starparam{value-type})}
  656. %\itemitem{\tt (values \param{value1-type} \param{value2-type} ...)}
  657. This \term{type specifier} can be used only as the \param{value-type} in a
  658. \typeref{function} \term{type specifier} or a \specref{the}
  659. \term{special form}. It is used to specify individual \term{types}
  660. when \term{multiple values} are involved.
  661. The \keyref{optional} and \keyref{rest} markers can appear in the \param{value-type} list;
  662. they indicate the parameter list of a \term{function} that,
  663. when given to \specref{multiple-value-call} along with the values,
  664. %would be suitable for receiving those values.
  665. would correctly receive those values.
  666. \issue{TYPE-SPECIFIER-ABBREVIATION:X3J13-JUN90-GUESS}
  667. The symbol \misc{*} may not be among the \param{value-types}.
  668. The symbol \misc{values} is not valid as a \term{type specifier};
  669. and, specifically, it is not an abbreviation for \f{(values)}.
  670. \endissue{TYPE-SPECIFIER-ABBREVIATION:X3J13-JUN90-GUESS}
  671. \endcom%{values}\ftype{Type Specifier}
  672. %%% ========== EQL
  673. \begincom{eql}\ftype{Type Specifier}
  674. \label Compound Type Specifier Kind::
  675. Combining.
  676. \label Compound Type Specifier Syntax::
  677. \Deftype{eql}{object}
  678. \label Compound Type Specifier Arguments::
  679. \param{object}---an \term{object}.
  680. \label Compound Type Specifier Description::
  681. Represents the \term{type}
  682. %% Replaced per Boyer/Kaufmann/Moore #6 (by X3J13 vote at May 4-5, 1994 meeting).
  683. %whose only \term{element} is \param{object}.
  684. of all \param{x} for which \f{(eql \param{object} \param{x})} is true.
  685. \issue{TYPE-SPECIFIER-ABBREVIATION:X3J13-JUN90-GUESS}
  686. The argument \param{object} is required. The \param{object} can be \misc{*},
  687. but if so it denotes itself (the symbol \misc{*})
  688. and does not represent an unspecified value.
  689. The \term{symbol} \misc{eql} is not valid as an \term{atomic type specifier}.
  690. %% Laubsch thinks this second part is gratuitous (and I agree). -kmp 20-Jan-92
  691. %and, specifically, it is not an abbreviation for \f{(eql *)}.
  692. \endissue{TYPE-SPECIFIER-ABBREVIATION:X3J13-JUN90-GUESS}
  693. \endcom%{eql}\ftype{Type Specifier}
  694. %%% ========== COERCE
  695. \begincom{coerce}\ftype{Function}
  696. \label Syntax::
  697. \DefunWithValues coerce {object result-type} {result}
  698. \label Arguments and Values::
  699. \param{object}---an \term{object}.
  700. \param{result-type}---a \term{type specifier}.
  701. \param{result}---an \term{object}, of \term{type} \param{result-type}
  702. except in situations described in \secref\RuleOfCanonRepForComplexRationals.
  703. \label Description::
  704. %% 4.8.0 3
  705. \term{Coerces} the \param{object} to \term{type} \param{result-type}.
  706. If \param{object} is already of \term{type} \param{result-type},
  707. the \param{object} itself is returned, regardless of whether it
  708. would have been possible in general to coerce an \term{object} of
  709. some other \term{type} to \param{result-type}.
  710. %% 4.8.0 4
  711. Otherwise, the \param{object} is \term{coerced} to \term{type} \param{result-type}
  712. according to the following rules:
  713. \beginlist
  714. \itemitem{\typeref{sequence}}
  715. \issue{CONCATENATE-SEQUENCE:SIGNAL-ERROR}
  716. % If the \param{result-type} is a \term{subtype} of \typeref{list},
  717. % the result will be a \term{list}.
  718. %
  719. % If the \param{result-type} is a \term{subtype} of \typeref{vector},
  720. % then if the implementation can determine the element type specified
  721. % for the \param{result-type}, the element type of the resulting array
  722. % is the result of \term{upgrading} that element type; or, if the
  723. % implementation can determine that the element type is unspecified (or \f{*}),
  724. % the element type of the resulting array is \typeref{t};
  725. % otherwise, an error is signaled.
  726. If the \param{result-type} is a \term{recognizable subtype} of \typeref{list},
  727. and the \term{object} is a \term{sequence},
  728. then the \param{result} is a \term{list}
  729. that has the \term{same} \term{elements} as \param{object}.
  730. If the \param{result-type} is a \term{recognizable subtype} of \typeref{vector},
  731. and the \term{object} is a \term{sequence},
  732. then the \param{result} is a \term{vector}
  733. that has the \term{same} \term{elements} as \param{object}.
  734. If \param{result-type} is a specialized \term{type},
  735. the \param{result} has an \term{actual array element type} that is the result of
  736. \term{upgrading} the element type part of that \term{specialized} \term{type}.
  737. If no element type is specified, the element type defaults to \typeref{t}.
  738. If the \term{implementation} cannot determine the element type, an error is signaled.
  739. % I don't understand this and I can't figure out where it came from.
  740. % It's stated below that an error is signaled if the appropriate result
  741. % cannot be constructed. --sjl 7 Mar 92
  742. %The consequences are undefined if the \param{result} is not of \term{type}
  743. %\param{result-type}.
  744. \endissue{CONCATENATE-SEQUENCE:SIGNAL-ERROR}
  745. \itemitem{\typeref{character}}
  746. If the \param{result-type} is \typeref{character}
  747. and the \term{object} is a \term{character designator},
  748. the \param{result} is the \term{character} it denotes.
  749. \issue{CHARACTER-LOOSE-ENDS:FIX}
  750. %Reference to INT-CHAR removed.
  751. \endissue{CHARACTER-LOOSE-ENDS:FIX}
  752. \itemitem{\typeref{complex}}
  753. %% 4.8.0 7
  754. If the \param{result-type} is \typeref{complex}
  755. %% "number" => "real" per Boyer/Kaufmann/Moore #7 (by X3J13 vote at May 4-5, 1994 meeting)
  756. %% -kmp 9-May-94
  757. and the \term{object} is a \term{real},
  758. then the \param{result} is obtained by constructing a \term{complex}
  759. whose real part is the \term{object} and
  760. whose imaginary part is the result of \term{coercing} an \term{integer} zero
  761. to the \term{type} of the \term{object} (using \funref{coerce}).
  762. (If the real part is a \term{rational}, however,
  763. then the result must be represented as a \term{rational} rather
  764. than a \term{complex}; \seesection\RuleOfCanonRepForComplexRationals.
  765. So, for example, \f{(coerce 3 'complex)} is permissible,
  766. but will return \f{3}, which is not a \term{complex}.)
  767. \itemitem{\typeref{float}}
  768. %% 4.8.0 6
  769. If the \param{result-type} is any of \typeref{float},
  770. \typeref{short-float},
  771. \typeref{single-float},
  772. \typeref{double-float},
  773. \typeref{long-float},
  774. and the \term{object} is a
  775. \issue{REAL-NUMBER-TYPE:X3J13-MAR-89}
  776. \term{real},
  777. \endissue{REAL-NUMBER-TYPE:X3J13-MAR-89}
  778. then the \param{result} is a \term{float} of \term{type} \param{result-type}
  779. which is equal in sign and magnitude to the \term{object} to whatever degree of
  780. representational precision is permitted by that \term{float} representation.
  781. (If the \param{result-type} is \typeref{float}
  782. and \param{object} is not already a \term{float},
  783. then the \param{result} is a \term{single float}.)
  784. \issue{FUNCTION-TYPE:X3J13-MARCH-88}
  785. \itemitem{\typeref{function}}
  786. If the \param{result-type} is \typeref{function},
  787. and \param{object} is any
  788. \issue{COERCING-SETF-NAME-TO-FUNCTION:ALL-FUNCTION-NAMES}
  789. %% Barmar asked what about (COERCE '(SETF symbol) 'FUNCTION)
  790. %% Mail sent to Quinquevirate. -kmp 3-Jun-91
  791. %% This change was the result of that discussion. kmp 14-May-93
  792. %\term{symbol}
  793. \term{function name}
  794. \endissue{COERCING-SETF-NAME-TO-FUNCTION:ALL-FUNCTION-NAMES}
  795. that is \term{fbound}
  796. but that is globally defined neither as a \term{macro name} nor as a \term{special operator},
  797. then the \param{result} is the \term{functional value} of \param{object}.
  798. If the \param{result-type} is \typeref{function},
  799. and \param{object} is a \term{lambda expression},
  800. then the \param{result} is a \term{closure} of \param{object}
  801. in the \term{null lexical environment}.
  802. \endissue{FUNCTION-TYPE:X3J13-MARCH-88}
  803. \itemitem{\typeref{t}}
  804. %% 4.8.0 8
  805. Any \param{object} can be \term{coerced} to an \term{object} \oftype{t}.
  806. In this case, the \param{object} is simply returned.
  807. \endlist
  808. \label Examples::
  809. \code
  810. (coerce '(a b c) 'vector) \EV #(A B C)
  811. (coerce 'a 'character) \EV #\\A
  812. (coerce 4.56 'complex) \EV #C(4.56 0.0)
  813. (coerce 4.5s0 'complex) \EV #C(4.5s0 0.0s0)
  814. (coerce 7/2 'complex) \EV 7/2
  815. (coerce 0 'short-float) \EV 0.0s0
  816. (coerce 3.5L0 'float) \EV 3.5L0
  817. (coerce 7/2 'float) \EV 3.5
  818. (coerce (cons 1 2) t) \EV (1 . 2)
  819. \endcode
  820. \issue{SEQUENCE-TYPE-LENGTH:MUST-MATCH}
  821. All the following \term{forms} should signal an error:
  822. \code
  823. (coerce '(a b c) '(vector * 4))
  824. (coerce #(a b c) '(vector * 4))
  825. (coerce '(a b c) '(vector * 2))
  826. (coerce #(a b c) '(vector * 2))
  827. (coerce "foo" '(string 2))
  828. (coerce #(#\\a #\\b #\\c) '(string 2))
  829. (coerce '(0 1) '(simple-bit-vector 3))
  830. \endcode
  831. \endissue{SEQUENCE-TYPE-LENGTH:MUST-MATCH}
  832. \label Affected By:\None.
  833. \label Exceptional Situations::
  834. If a coercion is not possible, an error \oftype{type-error} is signaled.
  835. \f{(coerce x 'nil)} always signals an error \oftype{type-error}.
  836. An error
  837. %KMP: I'm not sure UNDEFINED-FUNCTION is the right error type to signal here.
  838. %Barrett: Yeah. This isn't really right for `fbound but not function'. Make it ERROR.
  839. %KMP: Done
  840. \oftype{error} is signaled
  841. if the \param{result-type} is \typeref{function} but
  842. \param{object} is a \term{symbol} that is not \term{fbound} or
  843. if the \term{symbol} names a \term{macro} or a \term{special operator}.
  844. \issue{SEQUENCE-TYPE-LENGTH:MUST-MATCH}
  845. An error \oftype{type-error} should be signaled if \param{result-type}
  846. specifies the number of elements and \param{object} is of a different length.
  847. \endissue{SEQUENCE-TYPE-LENGTH:MUST-MATCH}
  848. \label See Also::
  849. \funref{rational}, \funref{floor}, \funref{char-code}, \funref{char-int}
  850. \label Notes::
  851. %% 4.8.0 9
  852. Coercions from \term{floats} to \term{rationals}
  853. and from \term{ratios} to \term{integers}
  854. are not provided because of rounding problems.
  855. \code
  856. (coerce x 't) \EQ (identity x) \EQ x
  857. \endcode
  858. \endcom
  859. %%% ========== DEFTYPE
  860. \begincom{deftype}\ftype{Macro}
  861. \issue{DECLS-AND-DOC}
  862. \label Syntax::
  863. \DefmacWithValues deftype {name lambda-list {\DeclsAndDoc} \starparam{form}} {name}
  864. \label Arguments and Values::
  865. \param{name}---a \term{symbol}.
  866. \param{lambda-list}---a \term{deftype lambda list}.
  867. \param{declaration}---a \misc{declare} \term{expression}; \noeval.
  868. %% 4.7.0 4
  869. \param{documentation}---a \term{string}; \noeval.
  870. \param{form}---a \term{form}.
  871. \label Description::
  872. %% 4.7.0 2
  873. \funref{deftype} defines a \term{derived type specifier} named \param{name}.
  874. The meaning of the new \term{type specifier} is given in terms of
  875. %tweaked --sjl 7 Mar 92
  876. %a body of code which expands the \term{type specifier} into another
  877. a function which expands the \term{type specifier} into another
  878. \term{type specifier}, which itself will be expanded if it contains
  879. references to another \term{derived type specifier}.
  880. The newly defined \term{type specifier} may be referenced as a list of
  881. the form {\tt (\param{name} \param{arg$\sub{1}$} \param{arg$\sub{2}$} ...)\/}.
  882. The number of arguments must be appropriate to the \param{lambda-list}.
  883. If the new \term{type specifier} takes no arguments,
  884. or if all of its arguments are optional,
  885. the \term{type specifier} may be used as an \term{atomic type specifier}.
  886. The \term{argument} \term{expressions} to the \term{type specifier},
  887. \param{arg$\sub{1}$} $\ldots$ \param{arg$\sub{n}$}, are not \term{evaluated}.
  888. Instead, these \term{literal objects} become the \term{objects} to which
  889. corresponding \term{parameters} become \term{bound}.
  890. The body of the \funref{deftype} \term{form}
  891. \issue{DEFMACRO-BLOCK-SCOPE:EXCLUDES-BINDINGS}
  892. (but not the \param{lambda-list})
  893. \endissue{DEFMACRO-BLOCK-SCOPE:EXCLUDES-BINDINGS}
  894. is
  895. \issue{FLET-IMPLICIT-BLOCK:YES}
  896. implicitly enclosed in a \term{block} named \param{name},
  897. \endissue{FLET-IMPLICIT-BLOCK:YES}
  898. and is evaluated as an \term{implicit progn},
  899. returning a new \term{type specifier}.
  900. \issue{DEFINING-MACROS-NON-TOP-LEVEL:ALLOW}
  901. The \term{lexical environment} of the body is the one which was current
  902. at the time the \macref{deftype} form was evaluated, augmented by the
  903. \term{variables} in the \param{lambda-list}.
  904. \endissue{DEFINING-MACROS-NON-TOP-LEVEL:ALLOW}
  905. \issue{RECURSIVE-DEFTYPE:EXPLICITLY-VAGUE}
  906. Recursive expansion of the \term{type specifier} returned as the expansion
  907. must terminate, including the expansion of \term{type specifiers} which
  908. are nested within the expansion.
  909. The consequences are undefined if the result of fully expanding a
  910. \term{type specifier} contains any circular structure, except within
  911. the \term{objects} referred to by \typeref{member} and \typeref{eql}
  912. \term{type specifiers}.
  913. \endissue{RECURSIVE-DEFTYPE:EXPLICITLY-VAGUE}
  914. %% 4.7.0 4
  915. \param{Documentation} is attached to \param{name} as a \term{documentation string}
  916. of kind \misc{type}.
  917. \issue{COMPILE-FILE-HANDLING-OF-TOP-LEVEL-FORMS:CLARIFY}
  918. % added qualification about top-level-ness --sjl 5 Mar 92
  919. If a \macref{deftype} \term{form} appears as a \term{top level form},
  920. the \term{compiler} must ensure that the \param{name} is recognized
  921. in subsequent \term{type} declarations.
  922. The \term{programmer} must ensure that the body of a \macref{deftype} form
  923. can be \term{evaluated} at compile time if the \param{name} is
  924. referenced in subsequent \term{type} declarations.
  925. If the expansion of a \term{type specifier} is not defined fully at compile time
  926. (perhaps because it expands into an unknown \term{type specifier} or a
  927. \declref{satisfies} of a named \term{function} that isn't defined in the
  928. compile-time environment), an \term{implementation} may ignore any references to
  929. this \term{type} in declarations and/or signal a warning.
  930. \endissue{COMPILE-FILE-HANDLING-OF-TOP-LEVEL-FORMS:CLARIFY}
  931. \label Examples::
  932. %% 4.7.0 5
  933. \code
  934. (defun equidimensional (a)
  935. (or (< (array-rank a) 2)
  936. (apply #'= (array-dimensions a)))) \EV EQUIDIMENSIONAL
  937. (deftype square-matrix (&optional type size)
  938. `(and (array ,type (,size ,size))
  939. (satisfies equidimensional))) \EV SQUARE-MATRIX
  940. \endcode
  941. \label Side Effects:\None.
  942. \label Affected By:\None.
  943. \label Exceptional Situations:\None.
  944. % addressed in the packages chapter. --sjl 5 Mar 92
  945. %\issue{LISP-SYMBOL-REDEFINITION:MAR89-X3J13}
  946. %The consequences are undefined if a \term{symbol} in \thepackage{common-lisp}
  947. %is used as the \param{name} argument.
  948. %\endissue{LISP-SYMBOL-REDEFINITION:MAR89-X3J13}
  949. \label See Also::
  950. \misc{declare},
  951. \macref{defmacro},
  952. \funref{documentation},
  953. {\secref\TypeSpecifiers},
  954. {\secref\DocVsDecls}
  955. \label Notes:\None.
  956. \endissue{DECLS-AND-DOC}
  957. \endcom
  958. %%% ========== SUBTYPEP
  959. \begincom{subtypep}\ftype{Function}
  960. \issue{SUBTYPEP-ENVIRONMENT:ADD-ARG}
  961. \label Syntax::
  962. \DefunWithValues subtypep
  963. {type-1 type-2 {\opt} environment}
  964. {subtype-p, valid-p}
  965. \label Arguments and Values::
  966. \param{type-1}---a \term{type specifier}.
  967. % acceptable to \funref{typep}
  968. \param{type-2}---a \term{type specifier}.
  969. % acceptable to \funref{typep}.
  970. %!!! as opposed to what? need a glossary term -kmp 15-Feb-91
  971. \param{environment}---an \term{environment} \term{object}.
  972. \Default{\nil, denoting the \term{null lexical environment}
  973. and the current \term{global environment}}
  974. %!!! Need to say what happens with the environment.
  975. \param{subtype-p}---a \term{generalized boolean}.
  976. \param{valid-p}---a \term{generalized boolean}.
  977. \label Description::
  978. %% 6.2.1 3
  979. If \param{type-1} is a \term{recognizable subtype} of \param{type-2},
  980. the first \term{value} is \term{true}.
  981. Otherwise, the first \term{value} is \term{false},
  982. indicating that either
  983. \param{type-1} is not a \term{subtype} of \param{type-2}, or else
  984. \param{type-1} is a \term{subtype} of \param{type-2}
  985. but is not a \term{recognizable subtype}.
  986. A second \term{value} is also returned indicating the `certainty' of
  987. the first \term{value}. If this value is \term{true}, then the first
  988. value is an accurate indication of the \term{subtype} relationship.
  989. (The second \term{value} is always \term{true} when the first \term{value}
  990. is \term{true}.)
  991. \Thenextfigure\ summarizes the possible combinations of \term{values}
  992. that might result.
  993. \tablefigthree{Result possibilities for subtypep}{Value 1}{Value 2}{Meaning}{
  994. \term{true} & \term{true} & \param{type-1} is definitely a \term{subtype} of
  995. \param{type-2}.\cr
  996. \term{false} & \term{true} & \param{type-1} is definitely not a \term{subtype} of
  997. \param{type-2}.\cr
  998. \term{false} & \term{false} & \funref{subtypep} could not determine the relationship,\cr
  999. & & so \param{type-1} might or might not be a \term{subtype} of
  1000. \param{type-2}.\cr
  1001. }
  1002. \issue{SUBTYPEP-TOO-VAGUE:CLARIFY-MORE}
  1003. \funref{subtypep} is permitted to return the
  1004. \term{values} \term{false} and \term{false} only when at least
  1005. one argument involves one of these \term{type specifiers}:
  1006. \declref{and},
  1007. % Added per Barrett:
  1008. \declref{eql},
  1009. the list form of \declref{function},
  1010. \declref{member},
  1011. \declref{not},
  1012. \declref{or},
  1013. \declref{satisfies},
  1014. or
  1015. \declref{values}.
  1016. (A \term{type specifier} `involves' such a \term{symbol} if,
  1017. after being \term{type expanded},
  1018. it contains that \term{symbol} in a position that would call for
  1019. its meaning as a \term{type specifier} to be used.)
  1020. One consequence of this is that if neither \param{type-1} nor \param{type-2}
  1021. involves any of these \term{type specifiers}, then \funref{subtypep} is obliged
  1022. to determine the relationship accurately. In particular, \funref{subtypep}
  1023. returns the \term{values} \term{true} and \term{true}
  1024. if the arguments are \funref{equal} and do not involve
  1025. any of these \term{type specifiers}.
  1026. \funref{subtypep} never returns a second value of \nil\ when both
  1027. \param{type-1} and \param{type-2} involve only
  1028. the names in \figref\StandardizedAtomicTypeSpecs, or
  1029. names of \term{types} defined by \macref{defstruct},
  1030. \macref{define-condition},
  1031. or \macref{defclass}, or
  1032. \term{derived types} that expand into only those names.
  1033. While \term{type specifiers} listed in \figref\StandardizedAtomicTypeSpecs\ and
  1034. names of \macref{defclass} and \macref{defstruct} can in some cases be
  1035. implemented as \term{derived types}, \funref{subtypep} regards them as primitive.
  1036. The relationships between \term{types} reflected by \funref{subtypep}
  1037. are those specific to the particular implementation. For example, if
  1038. an implementation supports only a single type of floating-point numbers,
  1039. in that implementation \f{(subtypep 'float 'long-float)}
  1040. returns the \term{values} \term{true} and \term{true}
  1041. (since the two \term{types} are identical).
  1042. \endissue{SUBTYPEP-TOO-VAGUE:CLARIFY-MORE}
  1043. \issue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  1044. For all \param{T1} and \param{T2} other than \f{*},
  1045. \f{(array \param{T1})} and \f{(array \param{T2})}
  1046. are two different \term{type specifiers} that always refer to the same sets of
  1047. things if and only if they refer to \term{arrays}
  1048. of exactly the same specialized representation, \ie
  1049. if \f{(upgraded-array-element-type '\param{T1})} and
  1050. \f{(upgraded-array-element-type '\param{T2})}
  1051. return two different \term{type specifiers} that always refer to the same sets of
  1052. \term{objects}.
  1053. This is another way of saying that
  1054. \f{`(array \param{type-specifier})}
  1055. and
  1056. \f{`(array ,(upgraded-array-element-type '\param{type-specifier}))}
  1057. refer to the same
  1058. set of specialized \term{array} representations.
  1059. For all \param{T1} and \param{T2} other than \f{*},
  1060. %tweaked --sjl 7 Mar 92
  1061. %the specified intersection for
  1062. % \f{(array \param{T1})}
  1063. %and \f{(array \param{T2})} is \nil\
  1064. the intersection of
  1065. \f{(array \param{T1})}
  1066. and \f{(array \param{T2})} is the empty set
  1067. if and only if they refer to \term{arrays} of different,
  1068. distinct specialized representations.
  1069. Therefore,
  1070. \code
  1071. (subtypep '(array T1) '(array T2)) \EV \term{true}
  1072. \endcode
  1073. if and only if
  1074. \code
  1075. (upgraded-array-element-type 'T1) and
  1076. (upgraded-array-element-type 'T2)
  1077. \endcode
  1078. return two different \term{type specifiers} that always refer to the same sets of
  1079. \term{objects}.
  1080. For all type-specifiers \param{T1} and \param{T2} other than \f{*},
  1081. \code
  1082. (subtypep '(complex T1) '(complex T2)) \EV \term{true}, \term{true}
  1083. \endcode
  1084. if:
  1085. \beginlist
  1086. \itemitem{1.} \f{T1} is a \term{subtype} of \f{T2}, or
  1087. \itemitem{2.} \f{(upgraded-complex-part-type '\param{T1})} and
  1088. \f{(upgraded-complex-part-type '\param{T2})}
  1089. return two different \term{type specifiers} that always refer to the
  1090. same sets of \term{objects}; in this case,
  1091. \f{(complex \param{T1})} and
  1092. \f{(complex \param{T2})} both refer to the
  1093. same specialized representation.
  1094. \endlist
  1095. The \term{values} are \term{false} and \term{true} otherwise.
  1096. The form
  1097. \code
  1098. (subtypep '(complex single-float) '(complex float))
  1099. \endcode
  1100. must return \term{true} in all implementations, but
  1101. \code
  1102. (subtypep '(array single-float) '(array float))
  1103. \endcode
  1104. returns \term{true} only in implementations that do not have a specialized \term{array}
  1105. representation for \term{single floats} distinct from that for other \term{floats}.
  1106. \endissue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  1107. %% KAB: What??
  1108. % When a type description is restricted by range or enumeration, and the
  1109. % restricted type is empty.
  1110. \label Examples::
  1111. \code
  1112. (subtypep 'compiled-function 'function) \EV \term{true}, \term{true}
  1113. (subtypep 'null 'list) \EV \term{true}, \term{true}
  1114. (subtypep 'null 'symbol) \EV \term{true}, \term{true}
  1115. (subtypep 'integer 'string) \EV \term{false}, \term{true}
  1116. (subtypep '(satisfies dummy) nil) \EV \term{false}, \term{implementation-dependent}
  1117. (subtypep '(integer 1 3) '(integer 1 4)) \EV \term{true}, \term{true}
  1118. (subtypep '(integer (0) (0)) 'nil) \EV \term{true}, \term{true}
  1119. (subtypep 'nil '(integer (0) (0))) \EV \term{true}, \term{true}
  1120. (subtypep '(integer (0) (0)) '(member)) \EV \term{true}, \term{true} ;or \term{false}, \term{false}
  1121. (subtypep '(member) 'nil) \EV \term{true}, \term{true} ;or \term{false}, \term{false}
  1122. (subtypep 'nil '(member)) \EV \term{true}, \term{true} ;or \term{false}, \term{false}
  1123. \endcode
  1124. \issue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  1125. Let \f{<aet-x>} and \f{<aet-y>} be two distinct \term{type specifiers} that
  1126. do not always refer to the same sets of
  1127. \term{objects}
  1128. in a given implementation, but for which
  1129. \funref{make-array}, will return an
  1130. \term{object} of the same \term{array} \term{type}.
  1131. Thus, in each case,
  1132. \code
  1133. (subtypep (array-element-type (make-array 0 :element-type '<aet-x>))
  1134. (array-element-type (make-array 0 :element-type '<aet-y>)))
  1135. \EV \term{true}, \term{true}
  1136. (subtypep (array-element-type (make-array 0 :element-type '<aet-y>))
  1137. (array-element-type (make-array 0 :element-type '<aet-x>)))
  1138. \EV \term{true}, \term{true}
  1139. \endcode
  1140. \endissue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  1141. If \f{(array <aet-x>)}
  1142. and \f{(array <aet-y>)} are different names for
  1143. exactly the same set of \term{objects},
  1144. these names should always refer to the same sets of
  1145. \term{objects}.
  1146. That implies that the following set of tests are also true:
  1147. \code
  1148. (subtypep '(array <aet-x>) '(array <aet-y>)) \EV \term{true}, \term{true}
  1149. (subtypep '(array <aet-y>) '(array <aet-x>)) \EV \term{true}, \term{true}
  1150. \endcode
  1151. \label Side Effects:\None.
  1152. \label Affected By:\None.
  1153. \label Exceptional Situations:\None.
  1154. \label See Also::
  1155. {\secref\Types}
  1156. \label Notes::
  1157. \issue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  1158. The small differences between the \funref{subtypep} specification for
  1159. the \typeref{array} and \typeref{complex} types are necessary because there
  1160. is no creation function for \term{complexes} which allows
  1161. the specification of the resultant part type independently of
  1162. the actual types of the parts. Thus in the case of \thetype{complex},
  1163. the actual type of the parts is referred to, although a \term{number}
  1164. can be a member of more than one \term{type}.
  1165. For example, \f{17} is of \term{type} \f{(mod 18)}
  1166. as well as \term{type} \f{(mod 256)} and \term{type} \typeref{integer};
  1167. and \f{2.3f5} is \oftype{single-float}
  1168. as well as \term{type} \typeref{float}.
  1169. \endissue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  1170. \endissue{SUBTYPEP-ENVIRONMENT:ADD-ARG}
  1171. \endcom
  1172. %%% ========== TYPE-OF
  1173. \begincom{type-of}\ftype{Function}
  1174. \label Syntax::
  1175. \DefunWithValues type-of {object} {typespec}
  1176. \label Arguments and Values::
  1177. \param{object}---an \term{object}.
  1178. \param{typespec}---a \term{type specifier}.
  1179. \label Description::
  1180. \issue{TYPE-OF-UNDERCONSTRAINED:ADD-CONSTRAINTS}
  1181. Returns a \term{type specifier}, \param{typespec}, for a \term{type}
  1182. that has the \param{object} as an \term{element}.
  1183. The \param{typespec} satisfies the following:
  1184. \beginlist
  1185. \itemitem{1.}
  1186. For any \param{object} that is an \term{element} of some \term{built-in type}:
  1187. \beginlist
  1188. \itemitem{a.}
  1189. the \term{type} returned is a \term{recognizable subtype} of that \term{built-in type}.
  1190. \itemitem{b.}
  1191. %KMP: I added MEMBER and EQL because they seemed to be missing only by accident.
  1192. % The discussion of TYPE-OF-UNDERCONSTRAINED seems to imply that MEMBER
  1193. % is missing due to editing error. And I think EQL was added later. -kmp 3-Jun-91
  1194. the \term{type} returned does not involve
  1195. \f{and},
  1196. \f{eql},
  1197. \f{member},
  1198. \f{not},
  1199. \f{or},
  1200. \f{satisfies},
  1201. or \f{values}.
  1202. \endlist
  1203. \itemitem{2.}
  1204. For all \param{objects}, \f{(typep \param{object} (type-of \param{object}))}
  1205. returns \term{true}.
  1206. %Per Barmar:
  1207. Implicit in this is that \term{type specifiers} which are
  1208. not valid for use with \funref{typep}, such as the \term{list} form of the
  1209. \funref{function} \term{type specifier}, are never returned by \funref{type-of}.
  1210. \itemitem{3.}
  1211. The \term{type} returned by \funref{type-of} is always a \term{recognizable subtype}
  1212. of the \term{class} returned by \funref{class-of}. That is,
  1213. \code
  1214. (subtypep (type-of \param{object}) (class-of \param{object})) \EV \term{true}, \term{true}
  1215. \endcode
  1216. \itemitem{4.}
  1217. For \param{objects} of metaclass \typeref{structure-class} or \typeref{standard-class},
  1218. \issue{TYPE-OF-AND-PREDEFINED-CLASSES:UNIFY-AND-EXTEND}
  1219. and for \term{conditions},
  1220. \endissue{TYPE-OF-AND-PREDEFINED-CLASSES:UNIFY-AND-EXTEND}
  1221. \funref{type-of} returns the \term{proper name} of the \term{class} returned
  1222. by \funref{class-of} if it has a \term{proper name},
  1223. and otherwise returns the \term{class} itself.
  1224. In particular, for \param{objects} created by the constructor function
  1225. of a structure defined with \macref{defstruct} without a \kwd{type} option,
  1226. \funref{type-of} returns the structure name; and for \param{objects} created
  1227. by \funref{make-condition}, the \param{typespec} is the \term{name} of the
  1228. \term{condition} \term{type}.
  1229. \issue{TYPE-OF-AND-PREDEFINED-CLASSES:TYPE-OF-HANDLES-FLOATS}
  1230. \itemitem{5.}
  1231. For each of the \term{types}
  1232. \typeref{short-float},
  1233. \typeref{single-float},
  1234. \typeref{double-float},
  1235. or \typeref{long-float}
  1236. of which the \param{object} is an \term{element},
  1237. the \param{typespec} is a \term{recognizable subtype} of that \term{type}.
  1238. \endissue{TYPE-OF-AND-PREDEFINED-CLASSES:TYPE-OF-HANDLES-FLOATS}
  1239. \endlist
  1240. \endissue{TYPE-OF-UNDERCONSTRAINED:ADD-CONSTRAINTS}
  1241. %(The CLOS specification has already specified that class objects are
  1242. %acceptable wherever \term{type specifiers} are, and in particular, as input to
  1243. %SUBTYPEP and TYPEP.)
  1244. %
  1245. %This proposal is intended to be consistent with 88-002R,
  1246. %and not to conflict with any of the definitions in that document.
  1247. %If \param{object} is not a user-defined named
  1248. %\term{structure}
  1249. %created by \macref{defstruct},
  1250. %\funref{type-of} returns a \term{type} of which
  1251. %\param{object}
  1252. %is a member.
  1253. %%% 4.9.0 3
  1254. %The result in this case is \term{implementation-dependent}.
  1255. %For example:
  1256. %
  1257. %\code
  1258. % (type-of "abc") \EV SIMPLE-STRING
  1259. % (type-of "abc") \EV STRING
  1260. % (type-of "abc") \EV ARRAY
  1261. %\endcode
  1262. %If \param{object} is a user-defined named
  1263. %\term{structure}
  1264. %created by \macref{defstruct}, then \funref{type-of}
  1265. %returns the type name
  1266. %of that \term{structure}.
  1267. \label Examples::
  1268. \code
  1269. \endcode
  1270. \issue{TYPE-OF-UNDERCONSTRAINED:ADD-CONSTRAINTS}
  1271. \code
  1272. (type-of 'a) \EV SYMBOL
  1273. (type-of '(1 . 2))
  1274. \EV CONS
  1275. \OV (CONS FIXNUM FIXNUM)
  1276. (type-of #c(0 1))
  1277. \EV COMPLEX
  1278. \OV (COMPLEX INTEGER)
  1279. (defstruct temp-struct x y z) \EV TEMP-STRUCT
  1280. (type-of (make-temp-struct)) \EV TEMP-STRUCT
  1281. (type-of "abc")
  1282. \EV STRING
  1283. \OV (STRING 3)
  1284. (subtypep (type-of "abc") 'string) \EV \term{true}, \term{true}
  1285. (type-of (expt 2 40))
  1286. \EV BIGNUM
  1287. \OV INTEGER
  1288. \OV (INTEGER 1099511627776 1099511627776)
  1289. \OV SYSTEM::TWO-WORD-BIGNUM
  1290. \OV FIXNUM
  1291. (subtypep (type-of 112312) 'integer) \EV \term{true}, \term{true}
  1292. (defvar *foo* (make-array 5 :element-type t)) \EV *FOO*
  1293. (class-name (class-of *foo*)) \EV VECTOR
  1294. (type-of *foo*)
  1295. \EV VECTOR
  1296. \OV (VECTOR T 5)
  1297. \endcode
  1298. \endissue{TYPE-OF-UNDERCONSTRAINED:ADD-CONSTRAINTS}
  1299. \label Affected By:\None.
  1300. \label Exceptional Situations:\None!
  1301. \label See Also::
  1302. \funref{array-element-type},
  1303. \funref{class-of},
  1304. \macref{defstruct},
  1305. \macref{typecase},
  1306. \funref{typep},
  1307. {\secref\Types}
  1308. \label Notes::
  1309. Implementors are encouraged to arrange for \funref{type-of} to return
  1310. \issue{TYPE-OF-UNDERCONSTRAINED:ADD-CONSTRAINTS}
  1311. %the most specific \term{type} that can be conveniently computed and
  1312. %is likely to be useful to the user.
  1313. a portable value.
  1314. %Barmar: "a type specifier defined in this standard"
  1315. %KMP: This is a little messy. The problem is that user-defined types are
  1316. % not directly described here,...
  1317. \endissue{TYPE-OF-UNDERCONSTRAINED:ADD-CONSTRAINTS}
  1318. \endcom
  1319. %%% ========== TYPEP
  1320. \begincom{typep}\ftype{Function}
  1321. \issue{SUBTYPEP-ENVIRONMENT:ADD-ARG}
  1322. \label Syntax::
  1323. \DefunWithValues typep {object type-specifier {\opt} environment} {generalized-boolean}
  1324. \label Arguments and Values::
  1325. \param{object}---an \term{object}.
  1326. \param{type-specifier}---any \term{type specifier} except
  1327. \issue{FUNCTION-TYPE}%
  1328. % The following will be deleted from the standard:
  1329. %
  1330. % \declref{function},
  1331. \endissue{FUNCTION-TYPE}%
  1332. \misc{values}, or a \term{type specifier} list
  1333. whose first element is either \misc{function} or \misc{values}.
  1334. \param{environment}---an \term{environment} \term{object}.
  1335. \Default{\nil, denoting the \term{null lexical environment}
  1336. and the and current \term{global environment}}
  1337. %!!! Need to say what happens with the environment.
  1338. \param{generalized-boolean}---a \term{generalized boolean}.
  1339. \label Description::
  1340. %% 6.2.1 2
  1341. \Predicate{object}{of the \term{type} specified by \param{type-specifier}}
  1342. % already stated elsewhere, not crucial here. --sjl 7 Mar 92
  1343. %\param{Object} can be of more than one \term{type},
  1344. %since one \term{type} can include another.
  1345. A \param{type-specifier} of the form \f{(satisfies fn)}
  1346. is handled by applying the function \f{fn} to \param{object}.
  1347. \issue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  1348. \f{(typep \param{object} '(array \param{type-specifier}))},
  1349. where \param{type-specifier} is not \f{*},
  1350. returns \term{true} if and only if \param{object} is an \term{array}
  1351. that could be the result
  1352. of supplying \param{type-specifier}
  1353. as the \kwd{element-type} argument to \funref{make-array}.
  1354. \f{(array *)} refers to all \term{arrays}
  1355. regardless of element type, while \f{(array \param{type-specifier})}
  1356. refers only to those \term{arrays}
  1357. that can result from giving \param{type-specifier} as the
  1358. \kwd{element-type} argument to \funref{make-array}.
  1359. A similar interpretation applies to \f{(simple-array \param{type-specifier})}
  1360. and \f{(vector \param{type-specifier})}.
  1361. \Seesection\ArrayUpgrading.
  1362. \f{(typep \param{object} '(complex \param{type-specifier}))}
  1363. returns \term{true} for all \term{complex} numbers that can result from
  1364. giving \term{numbers} of type \param{type-specifier}
  1365. to \thefunction{complex}, plus all other \term{complex} numbers
  1366. of the same specialized representation.
  1367. Both the real and the imaginary parts of any such
  1368. \term{complex} number must satisfy:
  1369. \code
  1370. (typep realpart 'type-specifier)
  1371. (typep imagpart 'type-specifier)
  1372. \endcode
  1373. \Seefun{upgraded-complex-part-type}.
  1374. \endissue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  1375. \label Examples::
  1376. \code
  1377. (typep 12 'integer) \EV \term{true}
  1378. (typep (1+ most-positive-fixnum) 'fixnum) \EV \term{false}
  1379. (typep nil t) \EV \term{true}
  1380. (typep nil nil) \EV \term{false}
  1381. (typep 1 '(mod 2)) \EV \term{true}
  1382. (typep #c(1 1) '(complex (eql 1))) \EV \term{true}
  1383. ;; To understand this next example, you might need to refer to
  1384. ;; \secref\RuleOfCanonRepForComplexRationals.
  1385. (typep #c(0 0) '(complex (eql 0))) \EV \term{false}
  1386. \endcode
  1387. \issue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  1388. Let \f{A\sssx} and \f{A\sssy} be two \term{type specifiers} that
  1389. denote different \term{types}, but for which
  1390. \code
  1391. (upgraded-array-element-type 'A\sssx)
  1392. \endcode
  1393. and
  1394. \code
  1395. (upgraded-array-element-type 'A\sssy)
  1396. \endcode
  1397. denote the same \term{type}. Notice that
  1398. \code
  1399. (typep (make-array 0 :element-type 'A\sssx) '(array A\sssx)) \EV \term{true}
  1400. (typep (make-array 0 :element-type 'A\sssy) '(array A\sssy)) \EV \term{true}
  1401. (typep (make-array 0 :element-type 'A\sssx) '(array A\sssy)) \EV \term{true}
  1402. (typep (make-array 0 :element-type 'A\sssy) '(array A\sssx)) \EV \term{true}
  1403. \endcode
  1404. \endissue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}
  1405. \label Affected By:\None.
  1406. \label Exceptional Situations::
  1407. %% 4.5.0.0 10
  1408. An error \oftype{error} is signaled if \param{type-specifier} is \f{values},
  1409. or a \term{type specifier} list whose first element is either
  1410. \misc{function} or \misc{values}.
  1411. The consequences are undefined if
  1412. the \param{type-specifier} is not a \term{type specifier}.
  1413. \label See Also::
  1414. \funref{type-of},
  1415. \funref{upgraded-array-element-type},
  1416. \funref{upgraded-complex-part-type},
  1417. {\secref\TypeSpecifiers}
  1418. \label Notes::
  1419. \term{Implementations} are encouraged to recognize and optimize the case of
  1420. \f{(typep \param{x} (the class \param{y}))},
  1421. since it does not involve any need for expansion
  1422. of \macref{deftype} information at runtime.
  1423. \code
  1424. \endcode
  1425. \endissue{SUBTYPEP-ENVIRONMENT:ADD-ARG}
  1426. \endcom
  1427. %-------------------- Type Errors --------------------
  1428. \begincom{type-error}\ftype{Condition Type}
  1429. \label Class Precedence List::
  1430. \typeref{type-error},
  1431. \typeref{error},
  1432. \typeref{serious-condition},
  1433. \typeref{condition},
  1434. \typeref{t}
  1435. \label Description::
  1436. \Thetype{type-error} represents a situation in which an \term{object} is not
  1437. of the expected type. The ``offending datum'' and ``expected type'' are initialized
  1438. by \theinitkeyargs{datum} and \kwd{expected-type} to \funref{make-condition},
  1439. and are \term{accessed} by the functions
  1440. \funref{type-error-datum} and \funref{type-error-expected-type}.
  1441. \label See Also::
  1442. \funref{type-error-datum}, \funref{type-error-expected-type}
  1443. \endcom%{type-error}\ftype{Condition Type}
  1444. %%% ========== TYPE-ERROR-DATUM
  1445. \begincom{type-error-datum, type-error-expected-type}\ftype{Function}
  1446. \label Syntax::
  1447. \DefunWithValues type-error-datum {condition} {datum}
  1448. \DefunWithValues type-error-expected-type {condition} {expected-type}
  1449. \label Arguments and Values::
  1450. \param{condition}---a \term{condition} \oftype{type-error}.
  1451. \param{datum}---an \term{object}.
  1452. \param{expected-type}---a \term{type specifier}.
  1453. \label Description::
  1454. \funref{type-error-datum} returns the offending datum in the \term{situation}
  1455. represented by the \param{condition}.
  1456. \funref{type-error-expected-type} returns the expected type of the
  1457. offending datum in the \term{situation} represented by the \param{condition}.
  1458. \label Examples::
  1459. \code
  1460. (defun fix-digits (condition)
  1461. (check-type condition type-error)
  1462. (let* ((digits '(zero one two three four
  1463. five six seven eight nine))
  1464. (val (position (type-error-datum condition) digits)))
  1465. (if (and val (subtypep 'fixnum (type-error-expected-type condition)))
  1466. (store-value 7))))
  1467. (defun foo (x)
  1468. (handler-bind ((type-error #'fix-digits))
  1469. (check-type x number)
  1470. (+ x 3)))
  1471. (foo 'seven)
  1472. \EV 10
  1473. \endcode
  1474. \label Side Effects:\None.
  1475. \label Affected By:\None.
  1476. \label Exceptional Situations:\None.
  1477. \label See Also::
  1478. \typeref{type-error},
  1479. {\secref\Conditions}
  1480. \label Notes:\None.
  1481. %% Shouldn't be needed. -kmp 1-Sep-91
  1482. %It is an error to use \macref{setf} with \funref{type-error-datum}.
  1483. %It is an error to use \macref{setf} with \funref{type-error-expected-type}.
  1484. \endcom
  1485. %%% ========== SIMPLE-TYPE-ERROR
  1486. \begincom{simple-type-error}\ftype{Condition Type}
  1487. \label Class Precedence List::
  1488. \issue{TYPE-OF-AND-PREDEFINED-CLASSES:UNIFY-AND-EXTEND}
  1489. \typeref{simple-type-error},
  1490. \typeref{simple-condition},
  1491. \typeref{type-error},
  1492. \typeref{error},
  1493. \typeref{serious-condition},
  1494. \typeref{condition},
  1495. \typeref{t}
  1496. \endissue{TYPE-OF-AND-PREDEFINED-CLASSES:UNIFY-AND-EXTEND}
  1497. \label Description::
  1498. \term{Conditions} \oftype{simple-type-error}
  1499. are like \term{conditions} \oftype{type-error},
  1500. except that they provide an alternate mechanism for specifying
  1501. how the \term{condition} is to be \term{reported};
  1502. \seetype{simple-condition}.
  1503. \label See Also::
  1504. \typeref{simple-condition},
  1505. \issue{FORMAT-STRING-ARGUMENTS:SPECIFY}
  1506. \funref{simple-condition-format-control},
  1507. \endissue{FORMAT-STRING-ARGUMENTS:SPECIFY}
  1508. \funref{simple-condition-format-arguments},
  1509. \funref{type-error-datum},
  1510. \funref{type-error-expected-type}
  1511. \endcom%{simple-type-error}\ftype{Condition Type}