[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: Jon L White <firstname.lastname@example.org>
- Subject: SIDE-EFFECT-FREE/STATELESS Functions
- From: David A. Moon <Moon@STONY-BROOK.SCRC.Symbolics.COM>
- Date: Fri, 13 May 88 21:00 EDT
- Cc: common-lisp@SAIL.STANFORD.EDU
- In-reply-to: <8805132146.AA28645@bhopal.lucid.com>
Date: Fri, 13 May 88 14:46:52 PDT
From: Jon L White <email@example.com>
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:
It refers to the function object in all cases. I omitted the word
"name" in one place, and I've added it in brackets below.
Date: Fri, 13 May 88 12:30 EDT
From: David A. Moon <Moon@STONY-BROOK.SCRC.Symbolics.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 [name] 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
"Future redefinitions" must mean "future rebindings of some symbol-function
I don't think I should admit to knowing what you mean by implementation
dependent concepts like "binding" and "cell". If the function was defined
by DEFUN, redefinition means evaluating a DEFUN for the same name.
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?
There was no function name field in the declaration syntax I showed.
The declarations apply to functions, not to function names, sorry about
the confusion. I don't know what it would mean to locally declare a
function to be free of side-effects; I think that's a property of the
function, not of a caller of the function.
(defun foo (x)
(declare (<simple-or-whatever> bar))
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.
I suspect I did not understand this comment. When defining a function
named bar, one declares properties of that function and all future
redefinitions of the function by putting a declare inside the function's
definition. When calling a function named bar, the declarations
attached to the definition that will be called are used.