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

issue DECLARATION-SCOPE



re: (1) The treatment of TYPE declarations contradicts proposal
    DECLARE-TYPE-FREE.  I don't think I could vote for either proposal
    without some better indication of how they are supposed to work
    together. 

The source of much confusion here has long been that TYPE declarations had 
to be treated differently from all other declarations; this was  because of 
the crazy prohibition found on p158 of CLtL.  Let's assume for now that 
DECLARE-TYPE-FREE is accepted; then I think we can just flush all crazy 
categorizations into "pervasive"/"non-pervasive" and  "free"/"bound" and 
simply say that declarations:
  (1) always include the lexical scope of the body of the special form 
      in which  they are found;
  (2) and furthermore, they also include the scope of the name-bindings, 
      if any, to which they apply.  [LET, LAMBDA, FLET, and LABELS 
      introduce "name bindings"; LOCALLY doesn't.]
Since the scope of a "name-binding" also includes the body as mentioned
in (1), then the only additional comment needed concerns LET* and LABELS.

We might need to be reminded that:
  -- for LET*, a variable's scope also includes the remaining value
     forms, for subsequent variable bindings;
  -- for LABELS, a function name's scope includes all the code for the
     functions being defined [presumably, compiler writers know how not 
     to get into an infinite loop of in-line substitutions in these cases];

We might also need to be reminded that new name-bindings "shadow" (after
a fashion) any higher level binding or declarations.  E.g., presuming
no proclamations, consider the inner let bindings of:
   (locally (declare (special x) (float y)) 
     (let ((x 5) (y 10)) 
       (print (+ x y))))
then x is bound is local, not special; and y is bound with no particular
type information [because the 'y' being bound is a different variable
than the 'y' declared float in the outter scope].



-- JonL --