merged two AD patches from sbcl-devel 2001-10-17..
.."inconsistency in FIND", fixing bug in %FIND-POSITION stuff
.."bug in APROPOS-LIST"
added tests for these bugs
* Martin Atzmueller fixed several other bugs:
** correct ERROR type for various file operations
** removing dead code
-* Alexey Dejneka fixed many bugs:
+* Alexey Dejneka fixed many bugs, both classic bugs and bugs he
+ discovered himself:
** misbehavior of WRITE-STRING/WRITE-LINE
** LOOP over keys of a hash table, LOOP bugs 49b and 81 and 103, and
several other LOOP problems as well
** DEFGENERIC with :METHOD options
** bug 126, in (MAKE-STRING N :INITIAL-ELEMENT #\SPACE))
** bug in the optimization of ARRAY-ELEMENT-TYPE
+ ** argument ordering in FIND with :TEST option
+ ** mishandled package designator argument in APROPOS-LIST
He also pointed out some bogus old entries in BUGS, and fixed
a number of bugs which came into existence in the pre7 branch
(internal to the CVS repository), so that they never showed
(when (fboundp symbol)
(write-string " (fbound)")))
-(defun apropos-list (string-designator &optional package external-only)
+(defun apropos-list (string-designator
+ &optional
+ package-designator
+ external-only)
#!+sb-doc
"Like APROPOS, except that it returns a list of the symbols found instead
of describing them."
- (if package
- (let ((string (stringify-name string-designator "APROPOS search"))
- (result nil))
- (do-symbols (symbol package)
- (when (and (eq (symbol-package symbol) package)
- (or (not external-only)
- (eq (find-symbol (symbol-name symbol) package)
- :external))
- (search string (symbol-name symbol) :test #'char-equal))
- (push symbol result)))
- result)
- (mapcan (lambda (package)
- (apropos-list string-designator package external-only))
- (list-all-packages))))
+ (if package-designator
+ (let ((package (find-undeleted-package-or-lose package-designator))
+ (string (stringify-name string-designator "APROPOS search"))
+ (result nil))
+ (do-symbols (symbol package)
+ (when (and (eq (symbol-package symbol) package)
+ (or (not external-only)
+ (eq (find-symbol (symbol-name symbol) package)
+ :external))
+ (search string (symbol-name symbol) :test #'char-equal))
+ (push symbol result)))
+ result)
+ (mapcan (lambda (package)
+ (apropos-list string-designator package external-only))
+ (list-all-packages))))
(defun apropos (string-designator &optional package external-only)
#!+sb-doc
:important t)
"expand inline"
'(%find-position-if (let ((test-fun (%coerce-callable-to-function 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
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
+;;;; tests for problems in the interface presented to the user/programmer
+
;;;; This software is part of the SBCL system. See the README file for
;;;; more information.
;;;;
;;;; more information.
(in-package :cl-user)
+\f
+;;;; properties of symbols, e.g. presence of doc strings for public symbols
;;; Check for fbound external symbols in public packages that have no
;;; argument list information. (This used to be possible when we got
;;; FIXME: It would probably be good to require here that every
;;; external symbol either has a doc string or has some good excuse
;;; (like being an accessor for a structure which has a doc string).
+\f
+;;;; tests of interface machinery
+
+;;; APROPOS should accept a package designator, not just a package, and
+;;; furthermore do the right thing when it gets a package designator.
+;;; (bug reported and fixed by Alexey Dejneka sbcl-devel 2001-10-17)
+(assert (< 0
+ (length (apropos-list "PRINT" :cl))
+ (length (apropos-list "PRINT"))))
(defun indiscriminate (fun)
(lambda (&rest rest) (apply fun rest)))
+;;; asymmetric test arg order example from ANSI FIND definition page
+(assert (eql #\space ; original example, depends on ASCII character ordering
+ (find #\d "here are some letters that can be looked at"
+ :test #'char>)))
+(assert (eql #\e ; modified example, depends only on standard a-z ordering
+ (find #\f "herearesomeletters" :test #'char>)))
+(assert (eql 4 ; modified more, avoids charset technicalities completely
+ (find 5 '(6 4) :test '>)))
+
;;; tests of FIND, POSITION, FIND-IF, and POSITION-IF (and a few for
;;; deprecated FIND-IF-NOT and POSITION-IF-NOT too)
(for-every-seq #()
(null (position-if-not #'packagep seq :key nil))))
(for-every-seq #(1)
'((null (find 2 seq))
+ ;; Get the argument ordering for asymmetric tests like #'> right.
+ ;; (bug reported and fixed by Alexey Dejneka sbcl-devel 2001-10-17)
+ (eql 1 (find 2 seq :test #'>))
(find 2 seq :key #'1+)
(find 1 seq :from-end t)
(null (find 1 seq :from-end t :start 1))
(for-every-seq #(1 2 3 2 1)
'((find 3 seq)
(find 3 seq :from-end 'yes)
+ (eql 1 (position 1.5 seq :test #'<))
(eql 0 (position 0 seq :key '1-))
(eql 4 (position 0 seq :key '1- :from-end t))
(eql 2 (position 4 seq :key '1+))
;;; This is the master value for LISP-IMPLEMENTATION-VERSION. It's
;;; separated into its own file here so that it's easy for
;;; text-munging make-ish or cvs-ish scripts to find and tweak it. For
-;;; the convenience of such scripts, only a trivial subset of Lisp
+;;; the convenience of such scripts, only a simple subset of Lisp
;;; reader syntax should be used here: semicolon-delimited comments,
;;; possible blank lines or other whitespace, and a single
;;; double-quoted string value alone on its own line.
;;; for internal versions, especially for internal versions off the
;;; main CVS branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"0.pre7.71"
+"0.pre7.72"