X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fseqtran.lisp;h=8282341a7687cfce7a02fe07fdd1f9fe919fc191;hb=ba7659c92f2b7fac7e9532a3db9114c5bdc4ab55;hp=e9be332d6cbeb950d454ea6eff3a28706c37d3ce;hpb=50305b602c3953440af716137a56f50cd204375d;p=sbcl.git diff --git a/src/compiler/seqtran.lisp b/src/compiler/seqtran.lisp index e9be332..8282341 100644 --- a/src/compiler/seqtran.lisp +++ b/src/compiler/seqtran.lisp @@ -203,7 +203,7 @@ ;; of the &REST vars.) `(lambda (result-type fun ,@seq-args) (declare (ignore result-type)) - (do ((really-fun (%coerce-callable-to-function fun)) + (do ((really-fun (%coerce-callable-to-fun fun)) ,@index-bindingoids (acc nil)) ((or ,@tests) @@ -324,7 +324,8 @@ (let ((leaf (ref-leaf use))) (and (global-var-p leaf) (eq (global-var-kind leaf) :global-function) - (not (null (member (leaf-name leaf) names :test #'equal)))))))) + (not (null (member (leaf-source-name leaf) names + :test #'equal)))))))) ;;; If CONT is a constant continuation, the return the constant value. ;;; If it is null, then return default, otherwise quietly give up the @@ -725,16 +726,18 @@ (return (values find position))) (when (>= index start) (when (funcall predicate key-i) - ;; This hack of dealing with non-NIL FROM-END for list data - ;; by iterating forward through the list and keeping track of - ;; the last time we found a match might be more screwy than - ;; what the user expects, but it seems to be allowed by the - ;; ANSI standard. (And if the user is screwy enough to ask - ;; for FROM-END behavior on list data, turnabout is fair play.) + ;; This hack of dealing with non-NIL FROM-END for list + ;; data by iterating forward through the list and keeping + ;; track of the last time we found a match might be more + ;; screwy than what the user expects, but it seems to be + ;; allowed by the ANSI standard. (And if the user is + ;; screwy enough to ask for FROM-END behavior on list + ;; data, turnabout is fair play.) ;; - ;; It's also not enormously efficient, calling PREDICATE and - ;; KEY more often than necessary; but all the alternatives - ;; seem to have their own efficiency problems. + ;; It's also not enormously efficient, calling PREDICATE + ;; and KEY more often than necessary; but all the + ;; alternatives seem to have their own efficiency + ;; problems. (if from-end (setf find i position index) @@ -750,14 +753,34 @@ :policy (> speed space) :important t) "expand inline" - '(%find-position-if (let ((test-fun (%coerce-callable-to-function test))) + '(%find-position-if (let ((test-fun (%coerce-callable-to-fun test))) + ;; I'm having difficulty believing I'm + ;; reading it right, but as far as I can see, + ;; the only guidance that ANSI gives for the + ;; order of arguments to asymmetric tests is + ;; the character-set dependent example from + ;; the definition of FIND, + ;; (find #\d "here are some.." :test #'char>) + ;; => #\Space + ;; (In ASCII, we have (CHAR> #\d #\SPACE)=>T.) + ;; (Neither the POSITION definition page nor + ;; section 17.2 ("Rules about Test Functions") + ;; seem to consider the possibility of + ;; asymmetry.) + ;; + ;; So, judging from the example, we want to + ;; do (FUNCALL TEST-FUN ITEM I), because + ;; (FUNCALL #'CHAR> #\d #\SPACE)=>T. + ;; + ;; -- WHN (whose attention was drawn to it by + ;; Alexey Dejneka's bug report/fix) (lambda (i) - (funcall test-fun i item))) + (funcall test-fun item i))) sequence from-end start end - (%coerce-callable-to-function key))) + (%coerce-callable-to-fun key))) ;;; The inline expansions for the VECTOR case are saved as macros so ;;; that we can share them between the DEFTRANSFORMs and the default @@ -810,6 +833,9 @@ start end element + ;; (See the LIST transform for a discussion of the correct + ;; argument order, i.e. whether the searched-for ,ITEM goes before + ;; or after the checked sequence element.) `(funcall ,test ,item (funcall ,key ,element))))) (def!macro %find-position-if-vector-macro (predicate sequence