0.pre8.100:
authorChristophe Rhodes <csr21@cam.ac.uk>
Thu, 24 Apr 2003 15:22:49 +0000 (15:22 +0000)
committerChristophe Rhodes <csr21@cam.ac.uk>
Thu, 24 Apr 2003 15:22:49 +0000 (15:22 +0000)
As suggested by Fufie (Stig Sandoe) on #lisp IRC, emit a
STYLE-WARNING for slots with names that are STRING= but not EQ.
... test that we can nonetheless still make them, given the
insecurity I feel about my format string wizardry.

src/pcl/std-class.lisp
tests/clos.impure.lisp
version.lisp-expr

index 34a1d5a..76b3343 100644 (file)
   (add-direct-subclasses class direct-superclasses)
   (make-class-predicate class predicate-name)
   (update-class class nil)
+  (do* ((slots (slot-value class 'slots) (cdr slots))
+       (dupes nil))
+       ((null slots) (when dupes
+                      (style-warn
+                       ;; FIXME: the indentation request ("~4I")
+                       ;; below appears not to do anything.  Finding
+                       ;; out why would be nice.  -- CSR, 2003-04-24
+                       "~@<slot names with the same SYMBOL-NAME but ~
+                         different SYMBOL-PACKAGE (possible package problem) ~
+                         for class ~S:~@:_~4I~<~@{~S~^~:@_~}~:>~@:>"
+                       class
+                       dupes)))
+    (let* ((slot (car slots))
+          (oslots (remove (slot-definition-name slot) (cdr slots)
+                          :test-not #'string= :key #'slot-definition-name)))
+      (when oslots
+       (pushnew (cons (slot-definition-name slot)
+                      (mapcar #'slot-definition-name oslots))
+                dupes
+                :test #'string= :key #'car))))
   (add-slot-accessors class direct-slots)
   (make-preliminary-layout class))
 
index b437d76..14787f5 100644 (file)
 (defclass frc-3 () ())
 (assert (typep (make-instance 'frc-1 :a 2) (find-class 'frc-1)))
 (assert (typep (make-instance 'frc-2 :a 3) (find-class 'frc-2)))
+\f
+;;; check that we can define classes with two slots of different names
+;;; (even if it STYLE-WARNs).
+(defclass odd-name-class ()
+  ((name :initarg :name)
+   (cl-user::name :initarg :name2)))
+(let ((x (make-instance 'odd-name-class :name 1 :name2 2)))
+  (assert (= (slot-value x 'name) 1))
+  (assert (= (slot-value x 'cl-user::name) 2)))
+\f
 ;;;; success
 (sb-ext:quit :unix-status 104)
index 95102c4..e46bf66 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"0.pre8.99"
+"0.pre8.100"