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

Declare Special



I support cleaning up the semantics of declarations.  I find myself
using *very* deffensive coding techniques instead of looking at
the manual every time I write a declaration.

I think the basic idea of putting the declaration inside the form it
is trying to affect is inherently un-lispish and will always be
confusing.  I think that we should define a set of special forms
that syntactically enclose the body they apply to and supply the
needed functionality.  Maybe in CL-2000 these can be made the standard.

Locally is a good start.  I have a question about its semantics, though.
Consider:
	(locally (declare (special foo))
	   (let ((foo <something>))
		(print foo)))
I cannot figure out what this does from CLtL.  Probably the binding is
not affected by locally, (even though the declaration is pervasive)
so in fact the binding *cannot* be referenced.  The reference to foo
is (presumably) affected by a pervasive declaration, so this code
fragment does something unpredictable.

I think two additional special forms would be helpful.  One would be
exactly like locally, except that it would pervasively affect bindings
as well as references to variables.  In other words, this would be
a lexically scoped version of proclaim.  (Perhaps call it proclaim-locally).

The last special form needed would supply the standard lexically
scoped declarations.  Hopefully this is not too confusing.
The syntax would again be identical to locally, but the scope would
be everything through the scope of the next enclosing binding.
(For variable declarations of course.)  For example:
	(lexical-locally (declare (special x))
	  ;; x special here.
	  (let ((x 3))	;binds x specially.
	    ;; x special here (and = 3)
	    (let ((x 4))	;Binds x lexically.
	       ....)))

People probably wouldn't want to use these at top-level, so there is
still a need for something like Pavel's suggestion.  Elsewhere these
forms would usually be clearer.