chiark / gitweb /
doc/concepts.tex: Typeset method rĂ´le names as identifiers.
[sod] / doc / clang.tex
index 0c6c4bb6c7a9cfe8852c4555d3e4dd3915091650..6d256ec4940a44a181aefcfdc97c3413a1add527 100644 (file)
@@ -38,19 +38,19 @@ The class hierarchy is shown in~\xref{fig:codegen.c-types.classes}.
 
 \begin{figure} \centering
   \parbox{10pt}{\begin{tabbing}
-    @|c-type| \\ \ind
-      @|qualifiable-c-type| \\ \ind
-        @|simple-c-type| \\ \ind
-          @|c-class-type| \- \\
-        @|tagged-c-type| \\ \ind
-          @|c-struct-type| \\
-          @|c-union-type| \\
-          @|c-enum-type| \- \\
-        @|c-atomic-type| \\
-        @|c-pointer-type| \- \\
-      @|c-array-type| \\
-      @|c-function-type| \\ \ind
-        @|c-keyword-function-type| \-
+    @|c-type|                                                   \\ \ind
+      @|qualifiable-c-type|                                     \\ \ind
+        @|simple-c-type|                                        \\ \ind
+          @|c-class-type|                                     \-\\
+        @|tagged-c-type|                                        \\ \ind
+          @|c-struct-type|                                      \\
+          @|c-union-type|                                       \\
+          @|c-enum-type|                                      \-\\
+        @|c-atomic-type|                                        \\
+        @|c-pointer-type|                                     \-\\
+      @|c-array-type|                                           \\
+      @|c-function-type|                                        \\ \ind
+        @|c-keyword-function-type|                            \-
   \end{tabbing}}
   \caption{Classes representing C types}
 \label{fig:codegen.c-types.classes}
@@ -125,9 +125,9 @@ type specifier.  Type specifiers fit into two syntactic categories.
 \end{describe}
 
 \begin{describe}{mac}
-    {defctype \=@{ @<name> @! (@<name>^+) @} @<type-spec> \+ \\
-                @[[ @|:export| @<export-flag> @]]^* \-
-       \nlret @<names>}
+    {defctype \=@{ @<name> @! (@<name>^+) @} @<type-spec>     \+\\
+                @[[ @|:export| @<export-flag> @]]^*
+       \-\nlret @<names>}
   Defines a new symbolic type specifier @<name>; if a list of @<name>s is
   given, then all are defined in the same way.  The type constructed by using
   any of the @<name>s is as described by the type specifier @<type-spec>.
@@ -151,10 +151,10 @@ type specifier.  Type specifiers fit into two syntactic categories.
 \end{describe}
 
 \begin{describe}{mac}
-    {define-c-type-syntax @<name> @<lambda-list> \\ \ind
-      @[[ @<declaration>^* @! @<doc-string> @]] \\
-      @<form>^* \-
-     \nlret @<name>}
+    {define-c-type-syntax @<name> @<lambda-list>                \\ \ind
+      @[[ @<declaration>^* @! @<doc-string> @]]                 \\
+      @<form>^*
+     \-\nlret @<name>}
   Defines the symbol @<name> as a new type operator.  When a list of the form
   @|(@<name> @<argument>^*)| is used as a type specifier, the @<argument>s
   are bound to fresh variables according to @<lambda-list> (a destructuring
@@ -564,23 +564,35 @@ In Sod, the leaf types are
 \end{describe}
 
 \begin{describe}{mac}
-    {define-simple-c-type \=@{ @<name> @! (@<name>^+) @} @<string> \+ \\
-                            @[[ @|:export| @<export-flag> @]] \-
-      \nlret @<name>}
+    {define-simple-c-type
+       \=@{ @<name> @! (@<name>^+) @}
+         @{ @<string> @! (@<string>^*) @}                     \+\\
+         @[[ @|:export| @<export-flag> @]]
+      \-\nlret @<name>}
   Define type specifiers for a new simple C type.  Each symbol @<name> is
   defined as a symbolic type specifier for the (unique interned) simple C
-  type whose name is the value of @<string>.  Further, each @<name> is
-  defined to be a type operator: the type specifier @|(@<name>
+  type whose name is the value of (the first) @<string>.  Further, each
+  @<name> is defined to be a type operator: the type specifier @|(@<name>
   @<qualifier>^*)| evaluates to the (unique interned) simple C type whose
-  name is @<string> and which has the @<qualifiers> (which are evaluated).
+  name is (the first) @<string> and which has the @<qualifiers> (which are
+  evaluated).
 
-  Furthermore, a variable @|c-type-@<name>| is defined, for the first @<name>
-  only, and initialized with the newly constructed C type object.
+  Each of the @<string>s is associated with the resulting type for retrieval
+  by \descref{find-simple-c-type}{fun}.  Furthermore, a variable
+  @|c-type-@<name>| is defined, for the first @<name> only, and initialized
+  with the newly constructed C type object.
 
   If @<export-flag> is true, then the @|c-type-@<name>| variable name, and
   all of the @<name>s, are exported from the current package.
 \end{describe}
 
+\begin{describe}{fun}
+    {find-simple-c-type @<string> @> @{ @<simple-c-type> @! @|nil| @}}
+  If @<string> is the name of a simple C type, as established by the
+  \descref{define-simple-c-type}[macro]{mac}, then return the corresponding
+  @|simple-c-type| object; otherwise, return @|nil|.
+\end{describe}
+
 \begin{describe}{cls}{tagged-c-type (qualifiable-c-type)
     \&key :qualifiers :tag}
   Provides common behaviour for C tagged types.  A @<tag> is a string
@@ -903,15 +915,15 @@ function type is the type of the function's return value.
 
   For example,
   \begin{prog}
-    (c-type (fun \=(lisp (c-type-subtype other-func)) \+ \\
+    (c-type (fun \=(lisp (c-type-subtype other-func))         \+\\
                    ("first" int) . (c-function-arguments other-func))
   \end{prog}
   evaluates to a function type like @|other-func|, only with an additional
   argument of type @|int| added to the front of its argument list.  This
   could also have been written
   \begin{prog}
-    (let (\=(args (c-function-arguments other-func)) \+ \\
-            (ret (c-type-subtype other-func))) \- \\ \ind
+    (let (\=(args (c-function-arguments other-func))          \+\\
+            (ret (c-type-subtype other-func)))                \-\\ \ind
       (c-type (fun \=(lisp ret) ("first" int) . args)
   \end{prog}
 \end{describe}
@@ -948,9 +960,9 @@ function type is the type of the function's return value.
   follows.
   \begin{prog}
     (fun \=@<return-type>
-           @{ (@<arg-name> @<arg-type>) @}^* \+ \\
+           @{ (@<arg-name> @<arg-type>) @}^*                  \+\\
            @{ \=:keys @{ (@<kw-name> @<kw-type> @[@<kw-default>@]) @}^*
-                   @[. @<form>@] @! \+ \\
+                   @[. @<form>@] @!                           \+\\
                  . @<form> @}
   \end{prog}
   where either the symbol @|:keys| appears literally in the specifier, or the
@@ -1005,23 +1017,45 @@ function type is the type of the function's return value.
   original list is not modified, but may share structure with the new list.
 \end{describe}
 
-\begin{describe}{fun}{merge-keyword-lists @<lists> @> @<list>}
+\begin{describe}{fun}
+    {merge-keyword-lists @<what-function> @<lists> @> @<list>}
   Merge a number of keyword-argument lists together and return the result.
 
-  The @<lists> parameter is a list consisting of a number of @|(@<args>
-  . @<origin>)| pairs: in each pair, @<args> is a list of
-  \descref{argument}{cls} objects, and @<origin> is either nil or an object
-  whose printed representation describes the origin of the corresponding
-  @<args> list, suitable for inclusion in an error message.
+  The @<what-function> is either nil or a function designator; see below.
+
+  The @<lists> parameter is a list consisting of a number of
+  @|(@<report-function> . @<args>)| pairs: in each pair, @<report-function>
+  is either nil or a function designator, and @<args> is a list of
+  \descref{argument}{cls} objects.
 
   The resulting list contains exactly one argument for each distinct argument
   name appearing in the input @<lists>; this argument will contain the
   default value from the earliest occurrence in the input @<lists> of an
   argument with that name.
 
-  If the same name appears multiple times with different types, an error is
-  signalled quoting the name, conflicting types, and (if non-nil) the origins
-  of the offending argument objects.
+  If the same name appears multiple times with different types, a continuable
+  error will be signalled, and one of the conflicting argument types will be
+  chosen arbitrarily.  The @<what-function> will be called to establish
+  information which will be reported to the user.  It will be called with no
+  arguments and is expected to return two values:
+  \begin{itemize}
+  \item a file location @<floc> or other object acceptable to
+    \descref{file-location}{gf}, to be used as the location of the main
+    error; and
+  \item an object @<what>, whose printed representation should be a noun
+    phrase describing the object for which the argument lists are being
+    combined.
+  \end{itemize}
+  The phrasing of the error message is `type mismatch in @<what>'.  Either,
+  or both, of @<floc> and @<what> may be nil, though this is considered poor
+  practice; if @<what-function> is nil, this is equivalent to a function
+  which returns two nil values.  Following the error, the @<report-function>s
+  for the @<args> lists containing the conflicting argument objects are
+  called, in an arbitrary order, with a single argument which is the
+  offending @|argument| object; the function is expected to issue information
+  messages (see \descref{info}{fun}) to give more detail for diagnosing the
+  conflict.  If a @<report-function> is nil, then nothing happens; this is
+  considered poor practice.
 \end{describe}
 
 \begin{describe}{fun}
@@ -1187,16 +1221,16 @@ Temporary names are represented by objects which implement a simple protocol.
 \end{describe}
 
 \begin{describe}{mac}
-    {definst @<code> (@<streamvar> \&key @<export>) (@<arg>^*) \\ \ind
-      @[[ @<declaration>^* @! @<doc-string> @]] \\
-      @<form>^* \-
-     \nlret @<code>}
+    {definst @<code> (@<streamvar> \&key @<export>) (@<arg>^*)  \\ \ind
+      @[[ @<declaration>^* @! @<doc-string> @]]                 \\
+      @<form>^*
+     \-\nlret @<code>}
 \end{describe}
 
 \begin{describe}{mac}
     {format-compound-statement
-        (@<stream> @<child> \&optional @<morep>) \\ \ind
-      @<declaration>^* \\
+        (@<stream> @<child> \&optional @<morep>)                \\ \ind
+      @<declaration>^*                                          \\
       @<form>^*}
 \end{describe}
 
@@ -1302,10 +1336,10 @@ Temporary names are represented by objects which implement a simple protocol.
 \end{describe}
 
 \begin{describe}{mac}
-    {with-temporary-var (@<codegen> @<var> @<type>) \\ \ind
-      @<declaration>^* \\
-      @<form>^* \-
-     \nlret @<value>^*}
+    {with-temporary-var (@<codegen> @<var> @<type>)             \\ \ind
+      @<declaration>^*                                          \\
+      @<form>^*
+     \-\nlret @<value>^*}
 \end{describe}
 
 \begin{describe}{fun}{deliver-expr @<codegen> @<target> @<expr>}