chiark / gitweb /
src/c-types-impl.lisp: Reorder `merge-keyword-lists' input lists.
[sod] / src / c-types-impl.lisp
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))))