Comment 0 for bug 736345

Revision history for this message
Jean-Philippe Paradis (hexstream) wrote :

What I do:
(defun foo (list-structure)
  (destructuring-bind (some pattern here) list-structure
    (declare (ignore list-structure)) ; for better readability
    'big-body-never-using-list-structure
    (values some pattern here)))

What happens:
SBCL says: "caught STYLE-WARNING: declaring unknown variable LIST-STRUCTURE to be ignored". It also doesn't complain about reading an ignored variable if I actually use LIST-STRUCTURE in scope of the declaration.

It seems that SBCL treats IGNORE and IGNORABLE as a "bound-only" declaration.

What I expected to happen:
If I understand correctly, IGNORE and IGNORABLE should be acceptable as free declarations further down than where the variable or function was introduced, and indicates that the variable or function won't be or might not be used within its scope, respectively.

I note that the CLHS page for IGNORE and IGNORABLE makes no mention at all of whether these are bound declarations or free declarations, which is troubling because there's at least one explicit mention in that regard for every other declaration on their respective pages. Seems like a bug in the spec to me.

Here's a workaround, but introducing an additional level of indentation for this is a little ridiculous IMHO, especially since the whole point is to make the big-body-never-using-list-structure more readable by assuring the reader that we're definitely not accessing LIST-STRUCTURE:

(defun foo (list-structure)
  (destructuring-bind (some pattern here) list-structure
    (let ((list-structure list-structure))
      (declare (ignore list-structure))
      'some-big-body-never-using-list-structure
      (values some pattern here))))

SBCL version: 1.0.42
uname -a: Linux dynamorph 2.6.32-29-generic #58-Ubuntu SMP Fri Feb 11 19:00:09 UTC 2011 i686 GNU/Linux

*features*:
(:SWANK :QUICKLISP :SB-BSD-SOCKETS-ADDRINFO :ASDF2 :ASDF :ANSI-CL :COMMON-LISP
 :SBCL :SB-DOC :SB-TEST :SB-LDB :SB-PACKAGE-LOCKS :SB-UNICODE :SB-EVAL
 :SB-SOURCE-LOCATIONS :IEEE-FLOATING-POINT :X86 :UNIX :ELF :LINUX :SB-THREAD
 :LARGEFILE :GENCGC :STACK-GROWS-DOWNWARD-NOT-UPWARD :C-STACK-IS-CONTROL-STACK
 :COMPARE-AND-SWAP-VOPS :UNWIND-TO-FRAME-AND-CALL-VOP :RAW-INSTANCE-INIT-VOPS
 :STACK-ALLOCATABLE-CLOSURES :STACK-ALLOCATABLE-VECTORS
 :STACK-ALLOCATABLE-LISTS :STACK-ALLOCATABLE-FIXED-OBJECTS :ALIEN-CALLBACKS
 :CYCLE-COUNTER :INLINE-CONSTANTS :MEMORY-BARRIER-VOPS :LINKAGE-TABLE
 :OS-PROVIDES-DLOPEN :OS-PROVIDES-PUTWC :OS-PROVIDES-SUSECONDS-T)