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

DECLARE SPECIAL Considered Confusing ?



Re: your question
    "How do I shadow the SPECIAL declaration if "every occurance of FOO is
     taken to be a ... special binding"?  E.g., How can I bind X lexically
     in the body of the following: (defun foo (x) (declare (special x))...)"
I thought Alan's proposal didn't just simply say "every occurance ...",
but rather "every occurance ..., unless shadowed by another declaration".

Thus, assuming there is to be an UNSPECIAL, or LOCAL, declaration, which is 
a no-op when the variable isn't declared or proclaimed special, then you can 
insulate some small piece of context from the larger lexical context in which 
it is embedded by just such a means.

Consider for example:
	(defmacro square (form)
	  `(let ((temp ,form))
	     (declare (local temp) (notype temp))
	     (* temp temp)))
Actually, many of us would probably have written "square" as:
	(defmacro square (form)
	  (let ((temp (gensym)))	;or maybe even "(gentemp)"
	    `(let ((,temp ,form))
	       (* ,temp ,temp))))
but that is no big issue (you'll probably prefer the former if you
are stuck with an implementation that can't GC symbols).

It seems to me that Alan's proposal infuses declarations with the same 
kind of scoping semantics that exists for variable bindings.  In the form
    (let ((a <something>))
      . . .
      (let ((a <something-else>))
        . . . 
      ))
the meaning of this is "a is bound to something, unless it is bound
to something else"; which is parallel to Alan's notion for declarations
that has (unfortunately) been called "shadowing".

I find the unification of these two scoping rules to be very attractive.

-- JonL --