[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Constant Functions
I agree with your analysis of the meaning of a function constant
declaration, but not with your comments on the desirability of
standardizing something of the sort.
I agree that the most common way of using this sort of knowledge would be a
"block compliation" mode, but I think finer granularity of control is also
In my compiler cleanup proposal, I suggest an "integration level" that
ranges from 0 to 3 (like an optimization quality). Any value greater than
0 allows the compiler to assume the function is constant, but increasing
values suggest increased inclination toward inline expansion. There is
also a "default integration level", which can be set by a proclamation and
applies to subsequently compiled DEFUNs.
It is worth standardizing on something of the sort insofar as it helps in
the writing of portable programs. Programs the redefine functions at run
time may not run in implementations that assume functions are constant.
This means that Common Lisp programs may only work in "go slow" mode.
If I were designing a new Lisp dialect, I would definitely have the
function defining form implicitly declare the function variable constant.
It is probably too late to make anything this sensible be the default in
Common Lisp, but it could be added as an upward compatible extension.
The 99.99 percent of programs that don't redefine functions could then have:
(PROCLAIM '(DEFAULT-INTEGRATION-LEVEL 1))
added at the beginning of the file, and could run fast.