[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DECLARE SPECIAL Considered Confusing



	
    Date: Mon, 7 Jul 86 20:59 EDT
    From: David A. Moon <Moon@STONY-BROOK.SCRC.Symbolics.COM>
    To: Pavel.pa@Xerox.COM
    Subject: DECLARE SPECIAL Considered Confusing
    In-Reply-To: <860705-165424-2715@Xerox>
    Message-ID: <860707205952.2.MOON@EUPHRATES.SCRC.Symbolics.COM>
    
     ...
	Date: 5 Jul 86 16:54 PDT
	From: Pavel.pa@Xerox.COM
    
	I have a question concerning some ambiguity in the description of the
	scope of a special declaration inside a LET.  Consider this code:
    
		(setq foo 6)
		(let ((foo 7))
			(let ((foo (1+ foo)))
				(declare (special foo))
				foo))
    
	Both Symbolics and CLISP return 8 for this, but VAXLISP returns 7.
    
    VAXLISP is incorrect here.  The SPECIAL declaration is pervasive for
    references (but non-pervasive for bindings).  Because SPECIAL is
    pervasive for references it affects the reference to foo inside 1+.
    
I don't wish to add to the confusion here, but my reading of pg 155
agrees with VaxLisp: the above example should return 7.  The outermost
LET binds a lexical var. named foo that is never referenced.  The
special declaration in the inner LET affects the variable being bound
by the LET (foo) and it affects the reference to foo in the explicit
body (i.e. the last reference to foo) and the reference to foo in the
init-form in the inner LET is also special.  The global value of foo
is 6, and 6 + 1 = 7.

-- Nick