0.pre7.139:
[sbcl.git] / src / code / coerce.lisp
index 6d0a3cf..c9630f6 100644 (file)
@@ -11,9 +11,6 @@
 
 (in-package "SB!IMPL")
 
-(file-comment
-  "$Header$")
-
 (macrolet ((def-frob (name result access src-type &optional typep)
             `(defun ,name (object ,@(if typep '(type) ()))
                (do* ((index 0 (1+ index))
@@ -84,7 +81,7 @@
 ;;; DEFTRANSFORMs, though.
 (declaim (inline coerce-to-list))
 (declaim (inline coerce-to-simple-string coerce-to-bit-vector coerce-to-vector))
-(defun coerce-to-function (object)
+(defun coerce-to-fun (object)
   ;; (Unlike the other COERCE-TO-FOOs, this one isn't inline, because
   ;; it's so big and because optimizing away the outer ETYPECASE
   ;; doesn't seem to buy us that much anyway.)
   (etypecase object
     (list (list-to-bit-vector* object))
     (vector (vector-to-bit-vector* object))))
+(defun coerce-to-simple-vector (x)
+  (if (simple-vector-p x)
+      x
+      (replace (make-array (length x)) x)))
 (defun coerce-to-vector (object output-type-spec)
   (etypecase object
     (list (list-to-vector* object output-type-spec))
 ;;; old working version
 (defun coerce (object output-type-spec)
   #!+sb-doc
-  "Coerces the Object to an object of type Output-Type-Spec."
+  "Coerce the Object to an object of type Output-Type-Spec."
   (flet ((coerce-error ()
           (/show0 "entering COERCE-ERROR")
           (error 'simple-type-error
                  :format-control "~S can't be converted to type ~S."
                  :format-arguments (list object output-type-spec)))
         (check-result (result)
-          #!+high-security
-          (check-type-var result output-type-spec)
+          #!+high-security (aver (typep result output-type-spec))
           result))
     (let ((type (specifier-type output-type-spec)))
       (cond
                  :format-control "~S can't be converted to type ~S."
                  :format-arguments (list object output-type-spec)))
         (check-result (result)
-          #!+high-security
-          (check-type-var result output-type-spec)
+          #!+high-security (aver (typep result output-type-spec))
           result))
     (let ((type (specifier-type output-type-spec)))
       (cond
        ((csubtypep type (specifier-type 'character))
         (character object))
        ((csubtypep type (specifier-type 'function))
-        (coerce-to-function object))
+        (coerce-to-fun object))
        ((numberp object)
         (let ((res
                (cond