From f601ededaa926a19ca60f95e8bc6f7f0d966f9d1 Mon Sep 17 00:00:00 2001 From: Alexey Dejneka Date: Wed, 25 Jun 2003 16:07:06 +0000 Subject: [PATCH] 0.8.1.4: Update documentation for type checking. --- OPTIMIZATIONS | 4 ++++ doc/beyond-ansi.sgml | 12 +++++----- doc/compiler.sgml | 59 ++++++++++++++++++++++++++------------------------ doc/efficiency.sgml | 3 +++ version.lisp-expr | 2 +- 5 files changed, 45 insertions(+), 35 deletions(-) diff --git a/OPTIMIZATIONS b/OPTIMIZATIONS index df2c49b..a53233a 100644 --- a/OPTIMIZATIONS +++ b/OPTIMIZATIONS @@ -162,3 +162,7 @@ It could be optimized to tests lowtag. -------------------------------------------------------------------------------- +#13 +FAST-+/FIXNUM and similar should accept unboxed arguments in interests +of representation selection. Problem: inter-TN dependencies. +-------------------------------------------------------------------------------- diff --git a/doc/beyond-ansi.sgml b/doc/beyond-ansi.sgml index 1558f3c..694898a 100644 --- a/doc/beyond-ansi.sgml +++ b/doc/beyond-ansi.sgml @@ -336,11 +336,9 @@ fixed addresses, a precondition for using copy-on-write to share code between multiple Lisp processes. is less important with modern generational garbage collectors. -The sb-ext:truly-the operator does what the -cl:the operator does in a more conventional -implementation of &CommonLisp;, declaring the type of its argument -without any runtime checks. (Ordinarily in &SBCL;, any type -declaration is treated as an assertion and checked at runtime.) +The sb-ext:truly-the declares the type of the +result of the operations, producing its argument; the declaration is +not checked. In short: don't use it. The sb-ext:freeze-type declaration declares that a type will never change, which can make type testing @@ -353,9 +351,11 @@ to it. This is appropriate for functions like sqrt, but is not appropriate for functions like aref, which can change their return values when the underlying data are changed. + - \ No newline at end of file + diff --git a/doc/compiler.sgml b/doc/compiler.sgml index e66bca3..131508b 100644 --- a/doc/compiler.sgml +++ b/doc/compiler.sgml @@ -376,11 +376,19 @@ types. Ideally, the compiler would consider all type declarations to be assertions, so that adding type declarations to a program, no matter how incorrect they might be, would never cause -undefined behavior. As of &SBCL; version 0.6.4, the compiler is known to +undefined behavior. As of &SBCL; version 0.8.1, the compiler is known to fall short of this goal in two areas: - The compiler trusts function return values which - have been established with proclaim. + Proclaimed constraints on argument and + result types of a function are supposed to be checked by the + function. If the function type is proclaimed before function + definition, type checks are inserted by the compiler, but the + standard allows the reversed order, in which case the compiler + will trust the declaration. + The compiler cannot check types of an unknown number + of values; if the number of generated values is unknown, but the + number of consumed is known, only consumed values are + checked. There are a few poorly characterized but apparently very uncommon situations where a type declaration in an unexpected location will be trusted and never checked by the @@ -439,8 +447,8 @@ an error if it is executed) and gives a warning. Type warnings are inhibited when the -extensions:inhibit-warnings optimization quality is -3. (See the section +sb-ext:inhibit-warnings optimization quality is +3. (See the section on compiler policy.) This can be used in a local declaration to inhibit type warnings in a code fragment that has spurious warnings. @@ -452,31 +460,26 @@ warnings. With the default compilation policy, all type declarations are -precisely checked, except in a few situations (such as using -the to constrain the argument type passed to a function) -where they are simply ignored instead. Precise checking means that the -check is done as though typep had been called with the -exact type specifier that appeared in the declaration. In &SBCL;, -adding type declarations makes code safer. (Except that as noted elsewhere, remaining bugs in -the compiler's handling of types unfortunately provide some exceptions to -this rule.) +precisely checked, except in a few situations where they are simply +ignored instead. Precise checking means that the check is done as +though typep had been called with the exact type +specifier that appeared in the declaration. In &SBCL;, adding type +declarations makes code safer. (Except that as noted elsewhere, remaining bugs +in the compiler's handling of types unfortunately provide some +exceptions to this rule.) If a variable is declared to be -(integer 3 17) -then its -value must always always be an integer between 3 -and 17. -If multiple type declarations apply to a single variable, then all the -declarations must be correct; it is as though all the types were -intersected producing a single and type specifier. - -Argument type declarations are automatically enforced. If you declare -the type of a function argument, a type check will be done when that -function is called. In a function call, the called function does the -argument type checking, which means that a more restrictive type -assertion in the calling function (e.g., from the) may be -lost. +(integer 3 17) then its value must always be an integer +between 3 and 17. If multiple type +declarations apply to a single variable, then all the declarations +must be correct; it is as though all the types were intersected +producing a single and type specifier. + +Argument and result type declarations are automatically +enforced. If you declare the type of a function argument, a type check +will be done when that function is called. In a function call, the +called function does the argument type checking. The types of structure slots are also checked. The value of a structure slot must always be of the type indicated in any diff --git a/doc/efficiency.sgml b/doc/efficiency.sgml index b4dc6aa..2f5516b 100644 --- a/doc/efficiency.sgml +++ b/doc/efficiency.sgml @@ -39,6 +39,9 @@ few other points to keep in mind. (This doesn't affect its ability to benefit from explicit type declarations involving the assigned variables, only its ability to get by without explicit type declarations.) + Since the time the &CMUCL; manual was written, &CMUCL; (and thus &SBCL;) has gotten a generational garbage collector. This means that there are some efficiency implications diff --git a/version.lisp-expr b/version.lisp-expr index 3f70143..71bf6ec 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"0.8.1.3" +"0.8.1.4" -- 1.7.10.4