From: ···········@my-deja.com
Subject: scope of a declare
Date: 
Message-ID: <823ugb$rok$1@nnrp1.deja.com>
(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.



Sent via Deja.com http://www.deja.com/
Before you buy.
From: Rob Warnock
Subject: Re: scope of a declare
Date: 
Message-ID: <825l19$7fnc4@fido.engr.sgi.com>
<···········@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		····@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