scope of a declare 
Author Message
 scope of a declare

(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.*-*-*.com/
Before you buy.



Sun, 19 May 2002 03:00:00 GMT  
 scope of a declare
+---------------
| (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

-----

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



Mon, 20 May 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. enlarge scope of an awk-declared variable ?

2. C++ declared parody of Smalltalk ;-)

3. Newbie: FILENAME not declared?

4. Declares fails with WindowPtr?

5. Help with "Declare"

6. Automatically declaring a global object

7. Declares to Cocoa?

8. Declare Function : passing a structure

9. DECLARES, Libs, Shared Libaries, plug-ins, etc.

10. Declare problem

11. I'm stupid with Declare and ByRef a Ptr

12. Declare's, Quicktime and datatypes

 

 
Powered by phpBB® Forum Software