chiark / gitweb /
src/c-types-impl.lisp: Reorder `merge-keyword-lists' input lists.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 8 Jun 2018 18:58:28 +0000 (19:58 +0100)
Prepend the `what' argument to the front of each argument list, rather
than having a (LIST . WHAT) pair.  Also, internally to
`merge-keyword-lists', keep the entries in the hash table as
(WHAT . ARG) rather than the other way around.

doc/clang.tex
src/builtin.lisp
src/c-types-impl.lisp
src/method-impl.lisp
src/method-proto.lisp

index ebe9d4e2db069cede474b2fcf0ff1edd9531a93c..18a8e1cfc1f41b8986f01021b840785b2c537eff 100644 (file)
@@ -1020,11 +1020,11 @@ function type is the type of the function's return value.
 \begin{describe}{fun}{merge-keyword-lists @<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 @<lists> parameter is a list consisting of a number of @|(@<origin>
+  . @<args>)| pairs: in each pair, @<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, 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
index 4d5b5cdccfdddf301ec0adddffcda805bce14e3d..77eca391e49ea79bbf09e7e14c684274273ac411 100644 (file)
@@ -300,10 +300,10 @@ (defmethod method-keyword-argument-lists
          (mapcan (lambda (class)
                    (let ((initargs (sod-class-initargs class)))
                      (and initargs
-                          (list (cons (mapcar #'sod-initarg-argument
-                                              initargs)
-                                      (format nil "initargs for ~A"
-                                              class))))))
+                          (list (cons (format nil "initargs for ~A"
+                                              class)
+                                      (mapcar #'sod-initarg-argument
+                                              initargs))))))
                  (sod-class-precedence-list
                   (effective-method-class method)))))
 
index 6b7c9042a5f2fa863801111e76f93799d3fa109a..e87964c66a09f924b3e0ad9922f5a1514dac12ec 100644 (file)
@@ -592,10 +592,10 @@ (export 'merge-keyword-lists)
 (defun merge-keyword-lists (lists)
   "Return the union of keyword argument lists.
 
-   The LISTS parameter consists of pairs (ARGS . WHAT), where ARGS is a list
-   of `argument' objects, and WHAT is either nil or a printable object
-   describing the origin of the corresponding argument list suitable for
-   quoting in an error message.
+   The LISTS parameter consists of pairs (WHAT . ARGS), where WHAT is either
+   nil or a printable object describing the origin of this argument list
+   suitable for inclusion in an error message, and ARGS is a list of
+   `argument' objects.
 
    The resulting list contains exactly one argument for each distinct
    argument name appearing in the input lists; this argument will contain the
@@ -607,24 +607,24 @@ (defun merge-keyword-lists (lists)
    conflicting pair of arguments."
 
   ;; The easy way through all of this is with a hash table mapping argument
-  ;; names to (ARGUMENT . WHAT) pairs.
+  ;; names to (WHAT . ARG) pairs.
 
   (let ((argmap (make-hash-table :test #'equal)))
 
     ;; Set up the table.  When we find a duplicate, check that the types
     ;; match.
     (dolist (item lists)
-      (let ((args (car item))
-           (what (cdr item)))
+      (let ((what (car item))
+           (args (cdr item)))
        (dolist (arg args)
          (let* ((name (argument-name arg))
                 (other-item (gethash name argmap)))
            (if (null other-item)
-               (setf (gethash name argmap) (cons arg what))
+               (setf (gethash name argmap) (cons what arg))
                (let* ((type (argument-type arg))
-                      (other (car other-item))
-                      (other-type (argument-type other))
-                      (other-what (cdr other-item)))
+                      (other-what (car other-item))
+                      (other (cdr other-item))
+                      (other-type (argument-type other)))
                  (unless (c-type-equal-p type other-type)
                    (error "Type mismatch for keyword argument `~A': ~
                            ~A~@[ (~A)~] doesn't match ~A~@[ (~A)~]"
@@ -636,7 +636,7 @@ (defun merge-keyword-lists (lists)
     (let ((result nil))
       (maphash (lambda (name item)
                 (declare (ignore name))
-                (push (car item) result))
+                (push (cdr item) result))
               argmap)
       (fix-and-check-keyword-argument-list result))))
 
index e3fb6aef7ea28be5be24e95ed2fb13682579420b..16ae56e94a9f8462d5f1c60f538339a43e446d59 100644 (file)
@@ -253,15 +253,15 @@ (defmethod method-keyword-argument-lists
     ((method effective-method) direct-methods)
   (with-slots (message) method
     (and (keyword-message-p message)
-        (cons (cons (c-function-keywords (sod-message-type message))
-                    (format nil "message ~A (at ~A)"
-                            message (file-location message)))
+        (cons (cons (format nil "message ~A (at ~A)"
+                            message (file-location message))
+                    (c-function-keywords (sod-message-type message)))
               (mapcar (lambda (m)
-                        (cons (c-function-keywords (sod-method-type m))
-                              (format nil "method for ~A on ~A (at ~A)"
+                        (cons (format nil "method for ~A on ~A (at ~A)"
                                       message
                                       (sod-method-class m)
-                                      (file-location m))))
+                                      (file-location m))
+                              (c-function-keywords (sod-method-type m))))
                       direct-methods)))))
 
 (defmethod shared-initialize :after
index 2d5f4715165088e2520139df923f427d212e74ad..a9865845f0fdf423eb6f6bb391d64e40c2b39853 100644 (file)
@@ -69,8 +69,8 @@ (defgeneric method-keyword-argument-lists (method direct-methods)
    "Returns a list of keyword argument lists to be merged.
 
    This should return a list suitable for passing to `merge-keyword-lists',
-   i.e., each element should be a pair consisting of a list of `argument'
-   objects and a string describing the source of the argument list."))
+   i.e., each element should be a pair consisting of a string describing the
+   source of the argument list, and a list of `argument' objects."))
 
 (export 'compute-sod-effective-method)
 (defgeneric compute-sod-effective-method (message class)