X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fcoerce.lisp;h=5d0ffa344a31515523f24bc6c5c088494f965d2d;hb=c716f6ea5255afeb33a1181535b5c067aa9d6aaa;hp=c9630f6c85d31daf6e09cdb2ceb39a988d195746;hpb=d40a76606c86722b0aef8179155f9f2840739b72;p=sbcl.git diff --git a/src/code/coerce.lisp b/src/code/coerce.lisp index c9630f6..5d0ffa3 100644 --- a/src/code/coerce.lisp +++ b/src/code/coerce.lisp @@ -11,7 +11,7 @@ (in-package "SB!IMPL") -(macrolet ((def-frob (name result access src-type &optional typep) +(macrolet ((def (name result access src-type &optional typep) `(defun ,name (object ,@(if typep '(type) ())) (do* ((index 0 (1+ index)) (length (length (the ,(ecase src-type @@ -27,20 +27,20 @@ (:list '(pop in-object)) (:vector '(aref in-object index)))))))) - (def-frob list-to-simple-string* (make-string length) schar :list) + (def list-to-simple-string* (make-string length) schar :list) - (def-frob list-to-bit-vector* (make-array length :element-type '(mod 2)) + (def list-to-bit-vector* (make-array length :element-type '(mod 2)) sbit :list) - (def-frob list-to-vector* (make-sequence-of-type type length) + (def list-to-vector* (make-sequence-of-type type length) aref :list t) - (def-frob vector-to-vector* (make-sequence-of-type type length) + (def vector-to-vector* (make-sequence-of-type type length) aref :vector t) - (def-frob vector-to-simple-string* (make-string length) schar :vector) + (def vector-to-simple-string* (make-string length) schar :vector) - (def-frob vector-to-bit-vector* (make-array length :element-type '(mod 2)) + (def vector-to-bit-vector* (make-array length :element-type '(mod 2)) sbit :vector)) (defun vector-to-list* (object) @@ -166,6 +166,11 @@ (not (fboundp object))) (error 'simple-type-error :datum object + ;; FIXME: SATISFIES FBOUNDP is a kinda bizarre broken + ;; type specifier, since the set of values it describes + ;; isn't in general constant in time. Maybe we could + ;; find a better way of expressing this error? (Maybe + ;; with the UNDEFINED-FUNCTION condition?) :expected-type '(satisfies fboundp) :format-control "~S isn't fbound." :format-arguments (list object))) @@ -208,6 +213,14 @@ ((csubtypep type (specifier-type '(complex long-float))) (complex (%long-float (realpart object)) (%long-float (imagpart object)))) + ((and (typep object 'rational) + (csubtypep type (specifier-type '(complex float)))) + ;; Perhaps somewhat surprisingly, ANSI specifies + ;; that (COERCE FOO 'FLOAT) is a SINGLE-FLOAT, not + ;; dispatching on *READ-DEFAULT-FLOAT-FORMAT*. By + ;; analogy, we do the same for complex numbers. -- + ;; CSR, 2002-08-06 + (complex (%single-float object))) ((csubtypep type (specifier-type 'complex)) (complex object)) (t