From: Paul F. D. <di...@dl...> - 2003-07-27 06:31:40
|
I noticed that the compiler is not infering the type returned by MAKE-SEQUENCE as well as it could: * (defun foo () (let ((x (make-sequence 'vector 10 :initial-element 'a))) (setf (aref x 4) 'b) x)) ; in: LAMBDA NIL ; (SETF (AREF X 4) 'B) ; --> SB-KERNEL:%ASET LET* ; ==> ; (SB-KERNEL:HAIRY-DATA-VECTOR-SET ARRAY SB-INT:INDEX SB-C::NEW-VALUE) ; ; note: unable to ; avoid runtime dispatch on array element type ; because: ; Upgraded element type of array is not known at compile time. ; compilation unit finished ; printed 1 note FOO * However, MAKE-SEQUENCE is required to return a (VECTOR T) in this case. When this is given explicitly, no warning is generated: * (defun foo2 () (let ((x (make-sequence '(vector t) 10 :initial-element 'a))) (setf (aref x 4) 'b) x)) FOO2 * Paul |
From: Paul F. D. <di...@dl...> - 2003-07-27 10:54:02
|
I wrote: > I noticed that the compiler is not infering the type returned by > MAKE-SEQUENCE as well as it could: The same thing happens with CONCATENATE: * (let ((x (concatenate 'vector '(a a a a a a a a a a)))) (setf (aref x 4) 'b) x) ; in: LAMBDA NIL ; (SETF (AREF X 4) 'B) ; --> SB-KERNEL:%ASET LET* ; ==> ; (SB-KERNEL:HAIRY-DATA-VECTOR-SET ARRAY SB-INT:INDEX SB-C::NEW-VALUE) ; ; note: unable to ; avoid runtime dispatch on array element type ; because: ; Upgraded element type of array is not known at compile time. ; compilation unit finished ; printed 1 note #(A A A A B A A A A A) * (let ((x (the (vector t) (concatenate 'vector '(a a a a a a a a a a))))) (setf (aref x 4) 'b) x) #(A A A A B A A A A A) * Paul |
From: Paul F. D. <di...@dl...> - 2003-07-27 11:20:13
|
I wrote: > I noticed that the compiler is not infering the type returned by > MAKE-SEQUENCE as well as it could: And also MERGE: * (let ((x (merge 'vector (list 1 2 3 4 5) (list 6 7 8 9 10) #'<))) (setf (aref x 4) 'b) x) ; in: LAMBDA NIL ; (SETF (AREF X 4) 'B) ; --> SB-KERNEL:%ASET LET* ; ==> ; (SB-KERNEL:HAIRY-DATA-VECTOR-SET ARRAY SB-INT:INDEX SB-C::NEW-VALUE) ; ; note: unable to ; avoid runtime dispatch on array element type ; because: ; Upgraded element type of array is not known at compile time. ; compilation unit finished ; printed 1 note #(1 2 3 4 B 6 7 8 9 10) * Paul |
From: Christophe R. <cs...@ca...> - 2003-07-27 15:25:18
|
"Paul F. Dietz" <di...@dl...> writes: > I noticed that the compiler is not infering the type returned by MAKE-SEQUENCE > as well as it could: Thanks. I've merged a patch for this (and CONCATENATE and MERGE) into sbcl-0.8.2.4. Cheers, Christophe -- http://www-jcsu.jesus.cam.ac.uk/~csr21/ +44 1223 510 299/+44 7729 383 757 (set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b))) (defvar b "~&Just another Lisp hacker~%") (pprint #36rJesusCollegeCambridge) |