1.0.0.22: Extensible sequences. (EXPERIMENTAL: Do Not Use As Food)
[sbcl.git] / src / code / pred.lisp
index 76286c4..6de30db 100644 (file)
       (and (complex-vector-p x)
            (do ((data (%array-data-vector x) (%array-data-vector data)))
                ((not (array-header-p data)) (simple-vector-p data))))))
+
+;;; Is X a SEQUENCE?  Harder than just (OR VECTOR LIST)
+(defun sequencep (x)
+  (or (listp x)
+      (vectorp x)
+      (let* ((slayout #.(info :type :compiler-layout 'sequence))
+             (depthoid #.(layout-depthoid (info :type :compiler-layout 'sequence)))
+             (layout (layout-of x)))
+        (when (layout-invalid layout)
+          (setq layout (update-object-layout-or-invalid x slayout)))
+        (if (eq layout slayout)
+            t
+            (let ((inherits (layout-inherits layout)))
+              (declare (optimize (safety 0)))
+              (and (> (length inherits) depthoid)
+                   (eq (svref inherits depthoid) slayout)))))))
 \f
 ;;;; primitive predicates. These must be supported directly by the
 ;;;; compiler.
 
 (defun equal (x y)
   #!+sb-doc
-  "Return T if X and Y are EQL or if they are structured components
-  whose elements are EQUAL. Strings and bit-vectors are EQUAL if they
-  are the same length and have identical components. Other arrays must be
-  EQ to be EQUAL."
+  "Return T if X and Y are EQL or if they are structured components whose
+elements are EQUAL. Strings and bit-vectors are EQUAL if they are the same
+length and have identical components. Other arrays must be EQ to be EQUAL."
   ;; Non-tail self-recursion implemented with a local auxiliary function
   ;; is a lot faster than doing it the straightforward way (at least
   ;; on x86oids) due to calling convention differences. -- JES, 2005-12-30