[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: labrea!Hornig%ALDERAAN.SCRC.Symbolics.COM@labrea.stanford.edu
- Subject: Issue: DECLARATION-SCOPE
- From: Jon L White <firstname.lastname@example.org>
- Date: Wed, 6 Jan 88 20:26:00 PST
- Cc: labrea!cl-cleanup%SAIL@labrea.stanford.edu
- In-reply-to: Charles Hornig's message of Tue, 5 Jan 88 08:21 EST <19880105132119.9.HORNIG@WINTER.SCRC.Symbolics.COM>
I welcome this proposal wholeheartedly -- it irons out another of those
brainos for which no one can now even remember a decent rationale.
However, there is one point I'd like to see pressed further. You propose:
The scope of a `normal' declaration is exactly the scope of the
associated lexical variable or function. . . .
SPECIAL declarations may be either `normal', affecting both a binding
and references, or `free', affecting only references. TYPE and IGNORE
declarations may only be `normal'. (There has been some discussion in
X3J13 of permitting `free' TYPE declarations.)
I think it is very shortsighted to limit the TYPE and IGNORE declarations
this way. In so far as IGNORE is merely advice to the compiler to stop
issuing worthless "bound, but unreferenced" warning messages, there is
no incompatiblity with it being in a LOCALLY form; it just means inhibit
warning messages for instances found in this lexical range.
Now the probable rationale for limiting the TYPE declaration must have
been so that it could affect the way in which bindings occur [e.g., in
pdp10 MacLisp, a flonum is stored on a float pdl, but a regular variable
is stored on the regpdl.] It is all well and fine if the user-supplied
scoping information can include the binding; but what if it can't? is it
so bad that the supplied information can be only partly useful in
optimization? Isn't it much better to permit the compiler to use the
useful part than to prohibit it from noticing at all? Take, for example:
(let ((x <some-value>))
(if (floatp x)
(locally (type float x)
(+ x 3.4))
(if (integerp x)
(ash x -3)
(error "What the heck"))))
If the compiler is prohibited from noticing the LOCALLY type declaration,
then it can't open-code the "+" operation; otherwise, it can open-code it.
True, it will be fetching x from a regular "pointer" location rather than
from a floating-point register (or whatever), but at least it will be
doing something that can make an order of magnitude difference in speed
(at least with Lucid's compiler).
After all, nothing compels a conforming compiler to do anything *different*
with a binding when it notices a TYPE declaration affecting the variable
This particular problem may be more than you wanted to bite off; if so,
maybe I'll be able to find the time to submit a separate proposal on it.
But since you've taken the plunge already on declaration scoping (and
since I've been so busy with product deadlines etc.) I thought you may
want to field the whole matter.
-- JonL --