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

SIDE-EFFECT-FREE/STATELESS Functions



Could you clarify how you are using "function" below? sometimes it seems
to apply to the symbol naming the routine being defined, and other times
it applies only to the compiled function object:

    Date: Fri, 13 May 88 12:30 EDT
    From: David A. Moon <Moon@STONY-BROOK.SCRC.Symbolics.COM>
    Subject: SIDE-EFFECT-FREE/STATELESS Functions
    In-Reply-To: <8805130856.AA25592@bhopal.lucid.com>

    The LT:SIDE-EFFECTS and LT:REPLICABILITY declarations license the
    compiler to assume that the current definition and all future
    redefinitions of the declared function will have the declared
    properties.  The reason these declarations exist is solely for that
    constraint on future redefinitions, since this is information that the
    compiler could easily deduce for itself by analyzing the function body.

    These declarations are placed in the body of a function and
    declare properties of the function being defined; these properties are
    available in all scopes where the name of the function is lexically
    available.

"Future redefinitions" must mean "future rebindings of some symbol-function
cell", right?  Also, it appears as though the declaration can only
appear in the body of the code to which it applies; thus you couldn't
tell the compiler that BAR is reducible in the following way?

    (defun foo (x) 
      (declare (<simple-or-whatever>  bar))
      (prog (...)
        A   (bar x)			;compiler might flush this call
            (when (< (random 5) 3)
              (return (bar 10)))))	;compiler could constant-fold this one

As I read your message, the only way the Symbolics compiler could obtain
information about 'bar', for use while compileing 'foo', is if 'foo' and
'bar' are being defined in the same lexical scope and the declare is
inside the definition of 'bar'.  If this isn't right, then maybe you
could give some examples.


-- JonL --