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

DECLARE SPECIAL Considered Confusing

It seems that Weinreb and Rees both like Pavel's proposal better than
the status quo, so it is at least worthy of careful consideration.  As
an individual, I like the proposal too, except for a couple of problems
that I think I see.  I'm not sure whether it is enough of an improvement
to be worth the trouble that such a change would cause, but in the case
of Spice Lisp, our interpeter does not correctly implement the current
rules at present.  (Our compiler does.)

Let's explore Pavel's idea, try to get it right, and then see if the
community feels it improves the coherence and consistency of the
langauge enough to be worth the trouble of changing things.

I used to feel that the clearest and simplest way to handle these
embedded declarations was to treat the scope of the declaration form as
wrapping the whole form in which it appeared.  Maybe this is an example
of what Moon calls "superficial simplicity".  The idea of letting the
scope of each declaration match the scope of the variable it applies to,
with any remaining declarations wrapping only the body of the form, is
perhaps a conceptually clearer way to handle this if we explain it
clearly enough.

I think that Pavel's treatment of LET, LET*, FLET, LABELS, and MACROLET
is good.  We would also need to say explicitly that a SPECIAL
declaration for a variable that is not bound by the form in question
wraps only the body, not the init forms.

We would also need to spell out in detail exactly how all this works in
DO, DO*, and friends.  It's ovious what should happen if you think in
terms of the expansion into a LET or LET* form, but we don't want to
leave that up to the readers to figure out.

I disagree with Pavel's proposal for LAMBDA (and, therefore, DEFUN).  He
suggests that the scope of all the declarations should coincide with the
scope of the first required parameter -- in effect, this follows the
current rule of making the declarations wrap everything.  That seems
wrong to me.  The variables are bound and the init-forms are computed
left-to-right, as in LET*.  If we change LET* in the way Pavel suggests,
we ought to change LAMBDA in the corresponding way: the scope of a
declaration matches the scope of the variable binding it applies to; the
scope of declarations that do not apply to variable-bindings created by
the lambda list includes only the body of the form.

-- Scott