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

New special form suggestion: LET-CONSTANT



    Date: Mon, 3 Aug 87 12:05:52 PDT
    From: edsel!kent-state!eb@labrea.stanford.edu (Eric Benson)

    There's actually no need for a declaration or special form.  LET will
    do fine all by itself.  If the expression to which the variable is
    bound is constant and there are no SETQs to the variable, all
    references to the variable may be legitimately replaced by the
    constant expression.  This is a very common optimization in Lisp
    compilers.  However, as far as I know it is not done by the Symbolics
    compiler.

It isn't an optimization in the Symbolics 3600, for most constants.  The
same is true in any other machine that keeps variables in registers and
doesn't have an immediate addressing mode capable of accomodating all Lisp
constants, I believe.

I'm not disagreeing that it is useful for compilers to make this optimization
in the cases where it is in fact an optimization.  I think your reasoning for
why Common Lisp has DEFCONSTANT but no corresponding local form is correct:
the local form isn't needed since the compiler has access to everything in
the scope of a local variable and hence can infer the same information.