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

Constant Functions



Isn't it the case that *any* proclaim about a function is equivalent to
saying that that aspect of the function is "constant"?  What  you are 
looking for is a way to say that "constant folding" is ok;  of course, 
the function must be defined and usable in the compilation environment
for this to work.  Generally speaking, "constant folding" is ok as long
as the function is side-effect free; so maybe that is the declaration
you want?

re: The declaration (CONSTANT-FUNCTION foo) . . .  With SPACE=0, SPEED=3 this
    should be equivalent to an INLINE declaration.

I don't think so, or at least not if what you primarily want is a way to
legitimze "constant folding".  For example,
   (defun run-around-and-double (x) 
       ...lots of contorted code ...
       ... ultimately returning (* 2 x) ...
    )
Then declaring this a constant-function should permit the compiler to convert
(run-around-and-double '6) into '12; but hopefully wouldn't cause in-lining
of (run-around-and-double x).  I see 'inline' and 'constant-function' as
independent dimensions.

re: As a special case (declare constant-function) in a DEFUN is equivalent
    to both a proclaim and the defun.

This is too special-casey.  Any declare in a DEFUN (or any other place that
admits 'declare') should have only local, lexical scope; or at least, so I 
think.



-- JonL --