X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/7f9f8b0729bcbe8da67957d56ea2dace7fd12bad..1edb774eed8bea3f6dbde5b02db6ecd209394cf8:/doc/misc.tex diff --git a/doc/misc.tex b/doc/misc.tex index b1ade39..b7ed6e5 100644 --- a/doc/misc.tex +++ b/doc/misc.tex @@ -39,7 +39,8 @@ of these are standard. \begin{describe}{mac} {with-gensyms (@{ @ @! (@ @[@@]) @}^*) \\ \ind @^* \\ - @
^*} + @^* + \-\nlret @^*} Bind each @ (a symbol, not evaluated) to a freshly made gensym whose name is based on the corresponding @ (a string, evaluated), and evaluate the @s as an implicit @|progn| in the resulting environment. @@ -52,7 +53,7 @@ of these are standard. @{ @ @! (@ @[@@]) @}^*) \\ \ind @^* \\ @^* - \nlret @} + \-\nlret @} This is a helper to ensure that macro expansions evaluate their arguments exactly once each, in the correct order. @@ -163,7 +164,8 @@ refer to the same place; but that doesn't work for these locatives. @{ @ @! (@{ @ @! (@ @[@@]) @}^*) @} \\ \ind @^* \\ - @^*} + @^* + \-\nlret @^*} This is a macro which hides the use of locatives from its caller using symbol-macros. @@ -182,7 +184,7 @@ refer to the same place; but that doesn't work for these locatives. An anaphoric macro implicitly binds a well-known name to a value of interest, in the course of doing something else. The concept was popularized by Paul -Graham \cite{FIXME:OnLisp}. +Graham \cite{graham-1993:on-lisp}. The macros described here all bind the variable @|it|. @@ -190,13 +192,13 @@ The macros described here all bind the variable @|it|. The symbol @|it| is exported by the @|sod-utilities| package. \end{describe} -\begin{describe}{mac}{aif @ @ @[@@]} +\begin{describe}{mac}{aif @ @ @[@@] @> @^*} Evaluate the @. If @ is non-nil, then bind @|it| to the resulting value and evaluate the @, returning all of its values. Otherwise, evaluate @, returning all of its values. \end{describe} -\begin{describe}{mac}{aand @^*} +\begin{describe}{mac}{aand @^* @> @^*} Evaluate each @ in turn. If any @ evaluates to nil, then stop and return nil. Each form except the first is evaluated with @|it| bound to the (necessarily non-nil) value of the previous form. If all but the @@ -205,12 +207,12 @@ The macros described here all bind the variable @|it|. (No @|aor| is provided, since @|it| would necessarily be bound to nil.) -\begin{describe}{mac}{awhen @ @^*} +\begin{describe}{mac}{awhen @ @^* @> nil} If @ evaluates to a non-nil value, bind @|it| to that value, and evaluate the @s as an implicit @|progn|. Otherwise, return nil. \end{describe} -\begin{describe}{mac}{acond @{ (@ @^*) @}^*} +\begin{describe}{mac}{acond @{ (@ @^*) @}^* @> @^*} Evaluate each @ in turn, until one of them produces a non-nil value. If the @ is followed by one or more @s, then bind @|it| to the non-nil value of the @ and evaluate the @s as @@ -219,21 +221,27 @@ The macros described here all bind the variable @|it|. \end{describe} \begin{describe*} - {\dhead{mac} - {acase @ @{ (@{ @ @! (@^*) @} @^*) @}^*} - \dhead{mac} - {aecase @ @{ (@{ @ @! (@^*) @} @^*) @}^*} - \dhead{mac}{atypecase @ @{ (@ @^*) @}^*} - \dhead{mac}{aetypecase @ @{ (@ @^*) @}^*}} + {\dhead{mac}{acase @ + @{ (@{ @ @! (@^*) @} @^*) @}^* + @> @^*} + \dhead{mac}{aecase @ + @{ (@{ @ @! (@^*) @} @^*) @}^* + @> @^*} + \dhead{mac}{atypecase @ @{ (@ @^*) @}^* + @> @^*} + \dhead{mac}{aetypecase @ @{ (@ @^*) @}^* + @> @^*}} These are like the Common Lisp macros @|case|, @|ecase|, @|typecase|, and @|etypecase|, except that @|it| is bound to the value of the @ while evaluating the matching @s. \end{describe*} -\begin{describe}{mac}{asetf @{ @ @ @}^*} +\begin{describe}{mac}{asetf @{ @ @ @}^* @> @^*} For each @ and @ in turn: bind @|it| to the current value of the @, evaluate the @ expression, and store the resulting - value back in the @. + value back in the @. Return the @(s) stored by the final + pair: there may be more than one value, e.g., if @ is a @|values| + form. For example, @|(asetf @ (1+ it))| is almost equivalent to @|(incf @)|, even if evaluating @ has side-effects. @@ -245,7 +253,7 @@ The macros described here all bind the variable @|it|. The following utilities make use of the introspection features of the CLOS metaobject protocol. -\begin{describe}{gf}{instance-initargs @} +\begin{describe}{gf}{instance-initargs @ @> @} Return a fresh list of plausible initargs for the given @. This is done by digging through the instance's class's slot definitions and @@ -497,6 +505,15 @@ be implemented fairly easily using @|merge-lists| below. the partial order. \end{describe} +\begin{describe}{fun}{cross-product \&rest @} + Return the cross product of the @. + + Each arguments may be a list, or a (non-nil) atom, which is equivalent to a + singleton list containing just that atom. Return a list of all possible + lists which can be constructed by taking one item from each argument list + in turn, in an arbitrary order. +\end{describe} + \begin{describe}{fun} {find-duplicates @ @ \&key :key :test} Call @ on each pair of duplicate items in a @. @@ -505,9 +522,14 @@ be implemented fairly easily using @|merge-lists| below. and $y$ are considered equal if and only if @|(funcall @ (funcall @ $x$) (funcall @ $y$))| returns non-nil. + The @ function is called as @|(funcall @ @ + @)|. Duplicates are reported in order; the @ item is + always the first matching item in the sequence. + This function will work for arbitrary @ functions, but it will run - much more efficiently if @ is @|eq|, @|eql|, @|equal|, or @|equalp| - (because it can use hash-tables). + much more efficiently if @ is @|eq|, @|eql|, @|equal|, or @|equalp|, + because it can use hash-tables. (The generic implementation for lists is + especially inefficient.) \end{describe} @@ -859,10 +881,23 @@ The following definitions are useful when working with conditions. Dijkstra. \end{describe} + +\subsection{Other exported symbols} + +\begin{describe}{sym}{int} + The symbol @|int| is exported by the @|sod-utilities| package, without + giving it any particular meaning. This is done because it's given + non-conflicting meanings by two different packages, and it's more + convenient for user code not to have to deal with an unnecessary symbol + conflict. Specifically, the @|sod| package wants to define it as a C type + specifier, see \descref{cls}{simple-c-type}; and @|optparse| wants to + define it as an option handler, see \descref{opt}{int}. +\end{describe} + %%%-------------------------------------------------------------------------- \section{Option parser} \label{sec:misc.optparse} -These symbols are defined in the @|optparse| package. +Most of these symbols are defined in the @|optparse| package. \begin{describe}{fun}{exit \&optional (@ 0) \&key :abrupt} \end{describe} @@ -910,8 +945,8 @@ These symbols are defined in the @|optparse| package. \dhead{fun}{setf (opt-negated-tag @