concept-args.tex 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. % -*- Mode: TeX -*-
  2. %% Error Checking in Function Calls
  3. \issue{ARGUMENT-MISMATCH-ERROR:MORE-CLARIFICATIONS}
  4. \beginsubSection{Argument Mismatch Detection}
  5. \beginsubsubsection{Safe and Unsafe Calls}
  6. \DefineSection{SafeAndUnsafeCalls}
  7. A \term{call} is a \newterm{safe call} if each of the following is
  8. either \term{safe} \term{code} or \term{system code} (other than
  9. \term{system code} that results from \term{macro expansion} of
  10. \term{programmer code}):
  11. \beginlist
  12. \itemitem{\bull} the \term{call}.
  13. \itemitem{\bull} the definition of the \term{function} being \term{called}.
  14. \itemitem{\bull} the point of \term{functional evaluation}
  15. \endlist
  16. The following special cases require some elaboration:
  17. \beginlist
  18. \itemitem{\bull}
  19. If the \term{function} being called is a \term{generic function},
  20. it is considered \term{safe} if all of the following are
  21. \issue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  22. % "safe" => "safe code or system code" per Moon #12 (first public review).
  23. \term{safe code} or \term{system code}:
  24. \endissue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  25. \beginlist
  26. \itemitem{--} its definition (if it was defined explicitly).
  27. \itemitem{--} the \term{method} definitions for all \term{applicable} \term{methods}.
  28. \itemitem{--} the definition of its \term{method combination}.
  29. \endlist
  30. \itemitem{\bull}
  31. For the form \f{(coerce \param{x} 'function)},
  32. where \param{x} is a \term{lambda expression},
  33. the value of the \term{optimize quality} \declref{safety}
  34. in the global environment at the time the \funref{coerce}
  35. is \term{executed} applies to the resulting \term{function}.
  36. \issue{SYNTACTIC-ENVIRONMENT-ACCESS:RETRACTED-MAR91}
  37. % \itemitem{\bull}
  38. % For the form \f{(enclose \param{x} \param{env})},
  39. % where \param{x} is a \term{lambda expression},
  40. % the value of the \term{optimize quality} \declref{safety}
  41. % in the \term{environment} \term{object} \param{env} applies
  42. % to the resulting \term{function}.
  43. \endissue{SYNTACTIC-ENVIRONMENT-ACCESS:RETRACTED-MAR91}
  44. \issue{GENERIC-FLET-POORLY-DESIGNED:DELETE}
  45. % \itemitem{\bull}
  46. % For \macref{generic-function},
  47. % \specref{generic-flet},
  48. % and \specref{generic-labels}
  49. % \term{forms}, the value of the \term{optimize quality} \declref{safety}
  50. % in the \term{lexical environment} in which the form appears applies
  51. % to the resulting \term{generic functions} and \term{method} definitions.
  52. \endissue{GENERIC-FLET-POORLY-DESIGNED:DELETE}
  53. \itemitem{\bull}
  54. For a call to \thefunction{ensure-generic-function}, the value of the
  55. \term{optimize quality} \declref{safety} in the \term{environment}
  56. \term{object} passed as the \kwd{environment} \term{argument} applies
  57. to the resulting \term{generic function}.
  58. \itemitem{\bull}
  59. For a call to \funref{compile} with a \term{lambda expression} as the
  60. \term{argument}, the value of the \term{optimize quality} \funref{safety}
  61. in the \term{global environment} at the time \funref{compile} is \term{called}
  62. applies to the resulting \term{compiled function}.
  63. \itemitem{\bull}
  64. For a call to \funref{compile} with only one argument, if the original definition
  65. of the \term{function} was \term{safe}, then the resulting \term{compiled function}
  66. must also be \term{safe}.
  67. \itemitem{\bull}
  68. A \term{call} to a \term{method} by \funref{call-next-method} must be
  69. considered \term{safe} if each of the following is
  70. \issue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  71. % "safe" => "safe code or system code" per Moon #12 (first public review).
  72. \term{safe code} or \term{system code}:
  73. \endissue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  74. \beginlist
  75. %% These first three reworded per RPG for wording consistency with
  76. %% another bullet list above. KAB concurred. -kmp 26-Jan-92
  77. % \itemitem{--} the \term{generic function}.
  78. % \itemitem{--} the \term{applicable} \term{methods}.
  79. % \itemitem{--} the \term{method combination}.
  80. \itemitem{--} the definition of the \term{generic function} (if it was defined explicitly).
  81. \itemitem{--} the \term{method} definitions for all \term{applicable} \term{methods}.
  82. \itemitem{--} the definition of the \term{method combination}.
  83. \itemitem{--} the point of entry into the body of the \term{method defining form},
  84. where the \term{binding} of \funref{call-next-method} is established.
  85. \itemitem{--} the point of \term{functional evaluation} of the name \funref{call-next-method}.
  86. \endlist
  87. \endlist
  88. An \newterm{unsafe call} is a \term{call} that is not a \term{safe call}.
  89. The informal intent is that the \term{programmer} can rely on a \term{call}
  90. to be \term{safe}, even when \term{system code} is involved, if all reasonable
  91. steps have been taken to ensure that the \term{call} is \term{safe}.
  92. For example, if a \term{programmer} calls \funref{mapcar} from \term{safe}
  93. \term{code} and supplies a \term{function} that was \term{compiled}
  94. as \term{safe}, the \term{implementation} is required to ensure that
  95. \funref{mapcar} makes a \term{safe call} as well.
  96. \beginsubsubsubsection{Error Detection Time in Safe Calls}
  97. \DefineSection{SafeCallDetectionTime}
  98. If an error is signaled in a \term{safe call},
  99. the exact point of the \term{signal} is \term{implementation-dependent}.
  100. In particular, it might be signaled at compile time or at run time,
  101. and if signaled at run time,
  102. it might be prior to, during, or after \term{executing} the \term{call}.
  103. However, it is always prior to the execution of the body of the \term{function}
  104. being \term{called}.
  105. \endsubsubsubsection%{Error Detection Time in Safe Calls}
  106. \endsubsubsection%{Safe and Unsafe Calls}
  107. \beginsubsubsection{Too Few Arguments}
  108. It is not permitted to supply too few \term{arguments} to a \term{function}.
  109. %For Moon:
  110. Too few arguments means fewer \term{arguments} than the number of \term{required parameters}
  111. for the \term{function}.
  112. \issue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  113. %% Per Moon #12 (first public review). -kmp 8-May-93
  114. %Otherwise, in a \term{safe call},
  115. If this \term{situation} occurs in a \term{safe call},
  116. \endissue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  117. an error \oftype{program-error} must be signaled;
  118. and in an \term{unsafe call} the \term{situation} has undefined consequences.
  119. \issue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  120. %% Commented out as redundant, per Moon #12 (first public review).
  121. %% I sure hope this doesn't lead to confusion down the road... -kmp 8-May-93
  122. %If an error is signaled in a \term{safe call},
  123. %the exact point of the \term{signal} is \term{implementation-dependent};
  124. %\seesection\SafeCallDetectionTime.
  125. \endissue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  126. \endsubsubsection%{Too Few Arguments}
  127. % ========================================
  128. \beginsubsubsection{Too Many Arguments}
  129. It is not permitted to supply too many \term{arguments} to a \term{function}.
  130. Too many arguments means more \term{arguments} than the number of \term{required parameters}
  131. plus the number of \term{optional parameters}; however, if the \term{function}
  132. uses \keyref{rest} or \keyref{key}, it is not possible for it to receive too many arguments.
  133. \issue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  134. %% Per Moon #12 (first public review). -kmp 8-May-93
  135. %Otherwise, in a \term{safe call},
  136. If this \term{situation} occurs in a \term{safe call},
  137. \endissue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  138. an error \oftype{program-error} must be signaled;
  139. and in an \term{unsafe call} the \term{situation} has undefined consequences.
  140. \issue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  141. %% Commented out as redundant, per Moon #12 (first public review).
  142. %% I sure hope this doesn't lead to confusion down the road... -kmp 8-May-93
  143. %If an error is signaled in a \term{safe call},
  144. %the exact point of the \term{signal} is \term{implementation-dependent};
  145. %\seesection\SafeCallDetectionTime.
  146. \endissue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  147. \endsubsubsection%{Too Many Arguments}
  148. % ========================================
  149. \beginsubsubsection{Unrecognized Keyword Arguments}
  150. \DefineSection{UnrecognizedKeyArgs}
  151. It is not permitted to supply a keyword argument to a \term{function}
  152. using a name that is not recognized by that \term{function}
  153. unless keyword argument checking is suppressed as described
  154. in \secref\SuppressingKeyArgChecks.
  155. \issue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  156. %% Per Moon #12 (first public review). -kmp 8-May-93
  157. %Otherwise, in a \term{safe call},
  158. If this \term{situation} occurs in a \term{safe call},
  159. \endissue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  160. an error \oftype{program-error} must be signaled;
  161. and in an \term{unsafe call} the \term{situation} has undefined consequences.
  162. \issue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  163. %% Commented out as redundant, per Moon #12 (first public review).
  164. %% I sure hope this doesn't lead to confusion down the road... -kmp 8-May-93
  165. %If an error is signaled in a \term{safe call},
  166. %the exact point of the \term{signal} is \term{implementation-dependent};
  167. %\seesection\SafeCallDetectionTime.
  168. \endissue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  169. \endsubsubsection%{Unrecognized Keyword Arguments}
  170. % ========================================
  171. \beginsubsubsection{Invalid Keyword Arguments}
  172. \DefineSection{InvalidKeyArgs}
  173. It is not permitted to supply a keyword argument to a \term{function}
  174. using a name that is not a \term{symbol}.
  175. \issue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  176. %% Per Moon #12 (first public review). -kmp 8-May-93
  177. %Otherwise, in a \term{safe call},
  178. If this \term{situation} occurs in a \term{safe call},
  179. \endissue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  180. an error \oftype{program-error} must be signaled
  181. unless keyword argument checking is suppressed as described
  182. in \secref\SuppressingKeyArgChecks;
  183. and in an \term{unsafe call} the \term{situation} has undefined consequences.
  184. \issue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  185. %% Commented out as redundant, per Moon #12 (first public review).
  186. %% I sure hope this doesn't lead to confusion down the road... -kmp 8-May-93
  187. %If an error is signaled in a \term{safe call},
  188. %the exact point of the \term{signal} is \term{implementation-dependent};
  189. %\seesection\SafeCallDetectionTime.
  190. \endissue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  191. \endsubsubsection%{Invalid Keyword Arguments}
  192. % ========================================
  193. \beginsubsubsection{Odd Number of Keyword Arguments}
  194. \DefineSection{OddNumberOfKeyArgs}
  195. \issue{ARGUMENT-MISMATCH-ERROR-AGAIN:CONSISTENT}
  196. An odd number of \term{arguments} must not be supplied for the \term{keyword parameters}.
  197. \issue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  198. %% Per Moon #12 (first public review). -kmp 8-May-93
  199. %Otherwise, in a \term{safe call},
  200. If this \term{situation} occurs in a \term{safe call},
  201. \endissue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  202. an error \oftype{program-error} must be signaled
  203. unless keyword argument checking is suppressed as described
  204. in \secref\SuppressingKeyArgChecks;
  205. and in an \term{unsafe call} the \term{situation} has undefined consequences.
  206. \issue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  207. %% Commented out as redundant, per Moon #12 (first public review).
  208. %% I sure hope this doesn't lead to confusion down the road... -kmp 8-May-93
  209. %If an error is signaled in a \term{safe call},
  210. %the exact point of the \term{signal} is \term{implementation-dependent};
  211. %\seesection\SafeCallDetectionTime.
  212. \endissue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  213. \endissue{ARGUMENT-MISMATCH-ERROR-AGAIN:CONSISTENT}
  214. \endsubsubsection%{Odd Number of Keyword Arguments}
  215. % ========================================
  216. \beginsubsubsection{Destructuring Mismatch}
  217. \DefineSection{DestructuringMismatch}
  218. \issue{ARGUMENT-MISMATCH-ERROR-AGAIN:CONSISTENT}
  219. When matching a \term{destructuring lambda list} against a \term{form},
  220. the pattern and the \term{form} must have compatible \term{tree structure},
  221. as described in \secref\ExtraDestructureInfo.
  222. Otherwise, in a \term{safe call},
  223. an error \oftype{program-error} must be signaled;
  224. and in an \term{unsafe call} the \term{situation} has undefined consequences.
  225. \issue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  226. %% Commented out as redundant, per Moon #12 (first public review).
  227. %% I sure hope this doesn't lead to confusion down the road... -kmp 8-May-93
  228. %If an error is signaled in a \term{safe call},
  229. %the exact point of the \term{signal} is \term{implementation-dependent};
  230. %\seesection\SafeCallDetectionTime.
  231. \endissue{ARGUMENT-MISMATCH-ERROR-MOON:FIX}
  232. \endissue{ARGUMENT-MISMATCH-ERROR-AGAIN:CONSISTENT}
  233. \endsubsubsection%{Destructuring Mismatch}
  234. % ========================================
  235. \beginsubsubsection{Errors When Calling a Next Method}
  236. If \funref{call-next-method} is called with \term{arguments}, the ordered
  237. set of \term{applicable} \term{methods} for the changed set of \term{arguments}
  238. for \funref{call-next-method} must be the same as the ordered set of
  239. \term{applicable} \term{methods} for the original \term{arguments} to the
  240. \term{generic function}, or else an error should be signaled.
  241. The comparison between the set of methods applicable to the
  242. new arguments and the set applicable to the original arguments is
  243. insensitive to order differences among methods with the same
  244. specializers.
  245. If \funref{call-next-method} is called with \term{arguments} that specify
  246. a different ordered set of \term{applicable} methods and there is no
  247. \term{next method} available, the test for different methods and the
  248. associated error signaling (when present) takes precedence over calling
  249. \funref{no-next-method}.
  250. \endsubsubsection%{Errors When Calling a Next Method}
  251. \endsubSection%{Argument Mismatch Detection}
  252. \endissue{ARGUMENT-MISMATCH-ERROR:MORE-CLARIFICATIONS}