0.7.12.5:
authorChristophe Rhodes <csr21@cam.ac.uk>
Mon, 27 Jan 2003 17:27:51 +0000 (17:27 +0000)
committerChristophe Rhodes <csr21@cam.ac.uk>
Mon, 27 Jan 2003 17:27:51 +0000 (17:27 +0000)
Fix bug 157: give TYPEP and friends an (ignored) optional
environment argument
... and open bug 237 documenting the implementation
deficiencies.
Also allow calls to MACROEXPAND and friends with an explicit NIL
environment argument to be compiled and executed.

12 files changed:
BUGS
NEWS
package-data-list.lisp-expr
src/code/array.lisp
src/code/deftypes-for-target.lisp
src/code/late-type.lisp
src/code/numbers.lisp
src/code/pred.lisp
src/code/typep.lisp
src/compiler/fndb.lisp
tests/interface.pure.lisp
version.lisp-expr

diff --git a/BUGS b/BUGS
index 27db05a..4dd6c3a 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -626,7 +626,6 @@ WORKAROUND:
 
   (note the space between the comma and the point)
 
-
 143:
   (reported by Jesse Bouwman 2001-10-24 through the unfortunately
   prominent SourceForge web/db bug tracking system, which is 
@@ -717,11 +716,6 @@ WORKAROUND:
   expansion, leaving garbage consisting of infinished blocks of the
   partially converted function.)
 
-157:
-  Functions SUBTYPEP, TYPEP, UPGRADED-ARRAY-ELEMENT-TYPE, and 
-  UPGRADED-COMPLEX-PART-TYPE should have an optional environment argument.
-  (reported by Alexey Dejneka sbcl-devel 2002-04-12)
-
 162:
   (reported by Robert E. Brown 2002-04-16) 
   When a function is called with too few arguments, causing the
@@ -1253,6 +1247,16 @@ WORKAROUND:
 
   The similar problem exists for TRULY-THE.
 
+237: "Environment arguments to type functions"
+  a. Functions SUBTYPEP, TYPEP, UPGRADED-ARRAY-ELEMENT-TYPE, and 
+     UPGRADED-COMPLEX-PART-TYPE now have an optional environment
+     argument, but they ignore it completely.  This is almost 
+     certainly not correct.
+  b. Also, the compiler's optimizers for TYPEP have not been informed
+     about the new argument; consequently, they will not transform
+     calls of the form (TYPEP 1 'INTEGER NIL), even though this is
+     just as optimizeable as (TYPEP 1 'INTEGER).
+
 DEFUNCT CATEGORIES OF BUGS
   IR1-#:
     These labels were used for bugs related to the old IR1 interpreter.
diff --git a/NEWS b/NEWS
index 408b56f..cd82a81 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1505,6 +1505,12 @@ changes in sbcl-0.7.13 relative to sbcl-0.7.12:
   * fixed a bug in LOG, so that LOG of a rational argument near 1 now
     gives a closer approximation to the right answer than previously.
     (thanks to Raymond Toy)
+  * fixed bug 157: TYPEP, SUBTYPEP, UPGRADED-ARRAY-ELEMENT-TYPE and
+    UPGRADED-COMPLEX-PART-TYPE now take (ignored, in all situations)
+    optional environment arguments, as required by ANSI.
+  * fixed bugs in other functions taking environment objects, allowing
+    calls with an explicit NIL environment argument to be compiled
+    without error.
   * fixed some bugs revealed by Paul Dietz' test suite:
     ** ARRAY-IN-BOUNDS-P now allows arbitrary integers as arguments,
        not just nonnegative fixnums;
index 6503d05..9a7d167 100644 (file)
@@ -1088,8 +1088,8 @@ is a good idea, but see SB-SYS re. blurring of boundaries."
              "JUST-DUMP-IT-NORMALLY"
              "KEY-INFO" "KEY-INFO-NAME"
              "KEY-INFO-P" "KEY-INFO-TYPE"
-             "LAYOUT-DEPTHOID"
-             "LAYOUT-INVALID-ERROR" "LEXENV"
+             "LAYOUT-DEPTHOID" "LAYOUT-INVALID-ERROR"
+            "LEXENV" "LEXENV-DESIGNATOR"
              "LINE-LENGTH"
              "ANSI-STREAM"
              "ANSI-STREAM-BIN" "ANSI-STREAM-BOUT"
index eb4c346..bf0bba6 100644 (file)
   (bug "called FAILED-%WITH-ARRAY-DATA with valid array parameters?"))
 \f
 ;;;; MAKE-ARRAY
-
+(defun upgraded-array-element-type (spec &optional environment)
+  #!+sb-doc
+  "Return the element type that will actually be used to implement an array
+   with the specifier :ELEMENT-TYPE Spec."
+  (declare (ignore environment))
+  (if (unknown-type-p (specifier-type spec))
+      (error "undefined type: ~S" spec)
+      (type-specifier (array-type-specialized-element-type
+                      (specifier-type `(array ,spec))))))
 (eval-when (:compile-toplevel :execute)
   (sb!xc:defmacro pick-vector-type (type &rest specs)
     `(cond ,@(mapcar (lambda (spec)
index 6c9ae10..2d65b2f 100644 (file)
 ;;; used in the ANSI spec (if this is in fact exactly the same thing)
 (sb!xc:deftype streamlike () '(or stream (member nil t)))
 
+;;; an object suitable for input to standard functions that accept
+;;; "environment objects" (of the ANSI glossary)
+(sb!xc:deftype lexenv-designator () '(or lexenv null))
+
 ;;; a thing that can be passed to FUNCALL & friends
 ;;;
 ;;; FIXME: should be FUNCTION-DESIGNATOR?
index e6be620..abb2340 100644 (file)
                              :complex-arg1 :complex-subtypep-arg1))))
 
 ;;; Just parse the type specifiers and call CSUBTYPE.
-(defun sb!xc:subtypep (type1 type2)
+(defun sb!xc:subtypep (type1 type2 &optional environment)
   #!+sb-doc
   "Return two values indicating the relationship between type1 and type2.
   If values are T and T, type1 definitely is a subtype of type2.
   If values are NIL and T, type1 definitely is not a subtype of type2.
   If values are NIL and NIL, it couldn't be determined."
+  (declare (ignore environment))
   (csubtypep (specifier-type type1) (specifier-type type2)))
 
 ;;; If two types are definitely equivalent, return true. The second
index b298f9f..34ad585 100644 (file)
 \f
 ;;;; COMPLEXes
 
-(defun upgraded-complex-part-type (spec)
+(defun upgraded-complex-part-type (spec &optional environment)
   #!+sb-doc
   "Return the element type of the most specialized COMPLEX number type that
    can hold parts of type SPEC."
+  (declare (ignore environment))
   (cond ((unknown-type-p (specifier-type spec))
         (error "undefined type: ~S" spec))
        ((subtypep spec 'single-float)
index 79944d2..b71a7be 100644 (file)
         (class-proper-name class)))
       name))))
 \f
-;;; FIXME: This belongs somewhere else, perhaps in code/array.lisp.
-(defun upgraded-array-element-type (spec)
-  #!+sb-doc
-  "Return the element type that will actually be used to implement an array
-   with the specifier :ELEMENT-TYPE Spec."
-  (if (unknown-type-p (specifier-type spec))
-      (error "undefined type: ~S" spec)
-      (type-specifier (array-type-specialized-element-type
-                      (specifier-type `(array ,spec))))))
-\f
 ;;;; equality predicates
 
 ;;; This is real simple, 'cause the compiler takes care of it.
index 6807198..5c7ee7b 100644 (file)
 ;;; test that the host Lisp object OBJECT translates to a target SBCL
 ;;; type TYPE. This behavior is needed e.g. to test for the validity
 ;;; of numeric subtype bounds read when cross-compiling.)
-(defun typep (object type)
+(defun typep (object type &optional environment)
   #!+sb-doc
   "Is OBJECT of type TYPE?"
+  (declare (ignore environment))
   ;; Actually interpreting types at runtime is done by %TYPEP. The
   ;; cost of the extra function call here should be negligible
   ;; compared to the cost of interpreting types. (And the compiler
index 6f9eaa7..9e0fa6a 100644 (file)
@@ -45,7 +45,7 @@
 
 ;;; These can be affected by type definitions, so they're not FOLDABLE.
 (defknown (upgraded-complex-part-type upgraded-array-element-type)
-         (type-specifier) type-specifier
+         (type-specifier &optional lexenv-designator) type-specifier
   (unsafely-flushable))
 \f
 ;;;; from the "Predicates" chapter:
@@ -56,7 +56,7 @@
 ;;; FIXNUMness) might be different between host and target. Perhaps
 ;;; this property should be protected by #-SB-XC-HOST? Perhaps we need
 ;;; 3-stage bootstrapping after all? (Ugh! It's *so* slow already!)
-(defknown typep (t type-specifier) t
+(defknown typep (t type-specifier &optional lexenv-designator) t
    ;; Unlike SUBTYPEP or UPGRADED-ARRAY-ELEMENT-TYPE and friends, this
    ;; seems to be FOLDABLE. Like SUBTYPEP, it's affected by type
    ;; definitions, but unlike SUBTYPEP, there should be no way to make
@@ -75,7 +75,8 @@
    ;; (UPGRADED-ARRAY-ELEMENT-TYPE and UPGRADED-COMPLEX-PART-TYPE have
    ;; behavior like SUBTYPEP in this respect, not like TYPEP.)
    (foldable))
-(defknown subtypep (type-specifier type-specifier) (values boolean boolean)
+(defknown subtypep (type-specifier type-specifier &optional lexenv-designator)
+  (values boolean boolean)
   ;; This is not FOLDABLE because its value is affected by type
   ;; definitions.
   ;;
@@ -96,7 +97,7 @@
 
 (sb!xc:deftype name-for-class () t)
 (defknown class-name (sb!xc:class) name-for-class (flushable))
-(defknown find-class (name-for-class &optional t lexenv)
+(defknown find-class (name-for-class &optional t lexenv-designator)
   (or sb!xc:class null) ())
 (defknown class-of (t) sb!xc:class (flushable))
 (defknown layout-of (t) layout (flushable))
 (defknown fmakunbound ((or symbol cons)) (or symbol cons)
   (unsafe explicit-check))
 (defknown (get-setf-method get-setf-method-multiple-value)
-  ((or list symbol) &optional lexenv)
+  ((or list symbol) &optional lexenv-designator)
   (values list list list form form)
   (flushable))
 (defknown apply (callable t &rest t) *) ; ### Last arg must be List...
 \f
 ;;;; from the "Macros" chapter:
 
-(defknown macro-function (symbol &optional lexenv)
+(defknown macro-function (symbol &optional lexenv-designator)
   (or function null)
   (flushable))
-(defknown (macroexpand macroexpand-1) (t &optional lexenv)
+(defknown (macroexpand macroexpand-1) (t &optional lexenv-designator)
   (values form &optional boolean))
 
-(defknown compiler-macro-function (t &optional lexenv)
+(defknown compiler-macro-function (t &optional lexenv-designator)
   (or function null)
   (flushable))
 \f
 ;;;; from the "Eval" chapter:
 
 (defknown eval (t) * (recursive))
-(defknown constantp (t &optional lexenv) boolean
+(defknown constantp (t &optional lexenv-designator) boolean
   (foldable flushable))
 \f
 ;;;; from the "Streams" chapter:
index 8ae4a04..6208384 100644 (file)
 (describe #0a0)
 (describe #(1 2 3))
 (describe #2a((1 2) (3 4)))
+
+;;; TYPEP, SUBTYPEP, UPGRADED-ARRAY-ELEMENT-TYPE and
+;;; UPGRADED-COMPLEX-PART-TYPE should be able to deal with NIL as an
+;;; environment argument
+(typep 1 'fixnum nil)
+(subtypep 'fixnum 'integer nil)
+(upgraded-array-element-type '(mod 5) nil)
+(upgraded-complex-part-type '(single-float 0.0 1.0) nil)
index ec7e398..14e8b22 100644 (file)
@@ -18,4 +18,4 @@
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
 
-"0.7.12.4"
+"0.7.12.5"