|
From: Pascal B. <pj...@in...> - 2003-05-07 03:50:19
|
William Harold Newman writes:
> If you can declare SRC and DST to be SIMPLE-STRING, then the code
> can be compiled most efficiently, and the notes should go away.
>=20
> If you don't *want* SRC and DST to be SIMPLE-STRINGs -- perhaps
> because you want FILL-POINTERs or something -- then there may be no
> completely satisfactory way to get rid of the optimization note. You
> could use SB-EXT:INHIBIT-WARNINGS, but that affects an entire region
> of code, not just a particular property of a particular symbol.
That's not that I don't want them to be SIMPLE-STRING. It's that I
don't want to have to decide that kind of low-level stuff. Perhaps I
don't use strings with FILL-POINTERs myself, but I don't know what the
clients of by package will want to do. That's the problem with type
analysis, you can only do it correctly on the whole system, that is in
the last resort, in the running system (when you have dynamically
generated or loaded code).
=20
> You might also be able to use the standard operator CL:REPLACE for this=
.
Yes, thank you, that's what I wanted. Sometimes it's faster to
rewrite a small function than to hunt the one already implemented in
Common-Lisp... Hopefully, SBCL does not say anything about REPLACE
working on sequences and me passing it strings.
> "Don't you *want* SRC and DST to be SIMPLE-STRINGs? I could compile
> it so efficiently. Couldn't you think about it a bit more? It might be
> very nice if they could be SIMPLE-STRINGs. It would be efficient."
> -- Python, trying to be helpful
It's too concerned by low-level stuff. It should do it if it pleases
it, but let us stay at a higher level.
It has something to say to absolutelly all my use of AREF! So I have
to throw all the warnings.
For example compiling the following source gives all these notices.
Why could not I decide how to build my own data structures? How would
you do it?
In particular, what type uncertainty is there in being a
(VECTOR (ARRAY BASE-CHAR)) ?
-----------------------(test.lisp)--------------------------------------
(DEFUN MAKE-PICTURE (WIDTH HEIGHT BACKGROUND)
"
RETURN: A new pict.
POST: for all x in [0..width-1], for all y in [0..height-1],
(eq background (picture-point-at result x y))
"
(ASSERT (CHARACTERP BACKGROUND))
;; (make-array (list height width) :initial-element background)
(LOOP WITH PICT =3D (MAKE-ARRAY (LIST HEIGHT)
:ELEMENT-TYPE '(ARRAY CHARACTER *))
FOR I FROM 0 BELOW HEIGHT
DO (SETF (AREF PICT I) (MAKE-STRING WIDTH :INITIAL-ELEMENT BACKGR=
OUND))
FINALLY (RETURN PICT))
) ;;MAKE-PICTURE
(DEFMACRO PICTURE-WIDTH (PICT)
"
RETURN: The width of the picture.
"
`(ARRAY-DIMENSION (AREF ,PICT 0) 0)
) ;;PICTURE-WIDTH
(DEFMACRO PICTURE-HEIGHT (PICT)
"
RETURN: The height of the picture.
"
`(ARRAY-DIMENSION ,PICT 0)
) ;;PICTURE-HEIGHT
(DEFUN PICTURE-POINT-AT (PICT X Y)
"
RETURN: The character at coordinate (x,y).
"
(DECLARE (TYPE (ARRAY (ARRAY CHARACTER *) *) PICT))
(SETQ X (TRUNCATE X) Y (TRUNCATE Y))
(WHEN (AND (<=3D 0 X) (<=3D 0 Y)
(< Y (PICTURE-HEIGHT PICT)) (< X (PICTURE-WIDTH PICT)))
(AREF (AREF PICT Y) X))
) ;;PICTURE-POINT-AT
(DEFUN PICTURE-DRAW-POINT (PICT X Y FOREGROUND)
"
PRE: inside <=3D> (AND (<=3D 0 X) (<=3D 0 Y)
(< Y (PICTURE-HEIGHT PICT))
(< X (PICTURE-WIDTH PICT)))
POST: inside =3D=3D> (EQ FOREGROUND (PICTURE-POINT-AT PICT X Y))
"
(DECLARE (TYPE (ARRAY (ARRAY CHARACTER *) *) PICT))
(SETQ X (TRUNCATE X) Y (TRUNCATE Y))
(WHEN (AND (<=3D 0 X) (<=3D 0 Y)
(< Y (PICTURE-HEIGHT PICT)) (< X (PICTURE-WIDTH PICT)))
(SETF (AREF (AREF PICT Y) X) FOREGROUND))
) ;;PICTURE-DRAW-POINT
;;;; test.lisp -- 2003-05-07 05:40:15 -- pascal =
;;;;
-------------------------------------------------------------------
Generating test.fasl...
; in: LAMBDA NIL
; (AREF PACKAGE COM.INFORMATIMAGO.COMMON-LISP.PACKAGE::FROM-SRC)
; --> LET* SB-KERNEL:HAIRY-DATA-VECTOR-REF MULTIPLE-VALUE-BIND=20
; --> MULTIPLE-VALUE-CALL=20
; =3D=3D>
; (SB-KERNEL:%DATA-VECTOR-AND-INDEX ARRAY SB-INT:INDEX)
;=20
; note: unable to
; optimize
; due to type uncertainty:
; The first argument is a BASE-STRING, not a SIMPLE-ARRAY.
; compilation unit finished
; printed 2 notes
; compiling file "/local/users/pascal/src/common/lisp/common-lisp/test.li=
sp" (written 07 MAY 2003 05:40:15 AM):
; recognizing DEFUN MAKE-PICTURE
; compiling DEFUN MAKE-PICTURE:=20
; compiling DEFMACRO PICTURE-WIDTH:=20
; compiling DEFMACRO PICTURE-HEIGHT:=20
; recognizing DEFUN PICTURE-POINT-AT
; compiling DEFUN PICTURE-POINT-AT:=20
; file: /local/users/pascal/src/common/lisp/common-lisp/test.lisp
; in: DEFUN PICTURE-POINT-AT
; (PICTURE-WIDTH PICT)
; --> ARRAY-DIMENSION AREF LET* SB-KERNEL:HAIRY-DATA-VECTOR-REF=20
; --> MULTIPLE-VALUE-BIND MULTIPLE-VALUE-CALL=20
; =3D=3D>
; (SB-KERNEL:%DATA-VECTOR-AND-INDEX ARRAY SB-INT:INDEX)
;=20
; note: unable to
; optimize
; due to type uncertainty:
; The first argument is a (VECTOR
; (ARRAY BASE-CHAR)), not a SIMPLE-ARRAY=
.
; (AREF PICT Y)
; --> LET* SB-KERNEL:HAIRY-DATA-VECTOR-REF MULTIPLE-VALUE-BIND=20
; --> MULTIPLE-VALUE-CALL=20
; =3D=3D>
; (SB-KERNEL:%DATA-VECTOR-AND-INDEX ARRAY SB-INT:INDEX)
;=20
; note: unable to
; optimize
; due to type uncertainty:
; The first argument is a (VECTOR
; (ARRAY BASE-CHAR)), not a SIMPLE-ARRAY=
.
; (AREF (AREF PICT Y) X)
; --> LET*=20
; =3D=3D>
; (SB-KERNEL:HAIRY-DATA-VECTOR-REF ARRAY SB-INT:INDEX)
;=20
; note: unable to
; avoid runtime dispatch on array element type
; because:
; Upgraded element type of array is not known at compile time.
; recognizing DEFUN PICTURE-DRAW-POINT
; compiling DEFUN PICTURE-DRAW-POINT:=20
; file: /local/users/pascal/src/common/lisp/common-lisp/test.lisp
; in: DEFUN PICTURE-DRAW-POINT
; (PICTURE-WIDTH PICT)
; --> ARRAY-DIMENSION AREF LET* SB-KERNEL:HAIRY-DATA-VECTOR-REF=20
; --> MULTIPLE-VALUE-BIND MULTIPLE-VALUE-CALL=20
; =3D=3D>
; (SB-KERNEL:%DATA-VECTOR-AND-INDEX ARRAY SB-INT:INDEX)
;=20
; note: unable to
; optimize
; due to type uncertainty:
; The first argument is a (VECTOR
; (ARRAY BASE-CHAR)), not a SIMPLE-ARRAY=
.
; (AREF PICT Y)
; --> LET* SB-KERNEL:HAIRY-DATA-VECTOR-REF MULTIPLE-VALUE-BIND=20
; --> MULTIPLE-VALUE-CALL=20
; =3D=3D>
; (SB-KERNEL:%DATA-VECTOR-AND-INDEX ARRAY SB-INT:INDEX)
;=20
; note: unable to
; optimize
; due to type uncertainty:
; The first argument is a (VECTOR
; (ARRAY BASE-CHAR)), not a SIMPLE-ARRAY=
.
; (SETF (AREF (AREF PICT Y) X) FOREGROUND)
; --> SB-KERNEL:%ASET LET*=20
; =3D=3D>
; (SB-KERNEL:HAIRY-DATA-VECTOR-SET ARRAY SB-INT:INDEX SB-C::NEW-VALUE)
;=20
; 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 6 notes
; /local/users/pascal/src/common/lisp/common-lisp/test.fasl written
; compilation finished in 0:00:01
-------------------------------------------------------------------
Compilation finished at Wed May 7 05:40:41
--=20
__Pascal_Bourguignon__ http://www.informatimago.com/
----------------------------------------------------------------------
Do not adjust your mind, there is a fault in reality.
|