Subject: Re: scope of a declare
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 1999/12/02
Newsgroups: comp.lang.lisp
Message-ID: <825l19$7fnc4@fido.engr.sgi.com>
<david_morse@my-deja.com> wrote:
+---------------
| (defun foo (x y z)
|   (declare (fixnum x y z))
|   (let* ((a (+ x y))
|          (a (- a z)))
|     (declare (fixnum a))
|     a))
| 
| Can anyone find any evidence in the hyperspec that the
| (declare (fixnum a)) refers to the inner binding of a or
| to both bindings?  It seems the safe thing to do is assume
| it only refers to the inner one.
+---------------

Section 3.3.4 "Declaration Scope" says:

	The scope of a bound declaration is the same as the
	lexical scope of the binding to which it applies...

[also see the def'n of "bound declaration"], so I'd assume it does.

But in any practical case where I was worried about it I'd just
hand-expand the "let*" and moot the issue:  ;-}  ;-}

	(defun foo (x y z)
	  (declare (fixnum x y z))
	  (let ((a (+ x y)))
	    (let ((a (- a z)))
	      (declare (fixnum a))
	      a))


-Rob

-----
Rob Warnock, 8L-846		rpw3@sgi.com
Applied Networking		http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.		Phone: 650-933-1673
1600 Amphitheatre Pkwy.		FAX: 650-933-0511
Mountain View, CA  94043	PP-ASEL-IA