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

Issue: FUNCTION-TYPE-REST-LIST-ELEMENT, FUNCTION-DECLARATION issues



My compiler cleanup proposal addresses a number of the issues being
discussed here.  We already went around once on cl-cleanup about the
meaning function type.

In my initial proposal, I had assumed a strict interpretation of
function type.  It was pointed out to me, that not only is CLTL very
clear about its non-restrictive interpretation, it is also very
difficult to use a strict interpretation within the framework of the
current type system.

Basically, the problem is that if you think about "function type
declarations" as being declarations about the type of the object which
is the function, then it isn't possible to use a strict
interpretation.  If you attempt to do so, then there will be cases
where a type declaration is necessary for a program to be correct, and
removing declarations can cause a program to be incorrect.  In
addition to problems with defining where declarations are necessary,
requiring declarations is also clearly in conflict with the stated
goals for declarations in Common Lisp.

Basically, the reason for this non-intuitive result is that a
declaration of a function's type actually makes a statement about what
definitions are legal, rather than what calls are legal.  What a
compiler really wants to know is what calls are legal.

The solution I suggest in my proposal is to introduce a mechanism that
allows arbitrary information about a function definition to be bound
at compile time.  You don't declare the function type, you just define
the function, with any appropriate argument type declarations.
Since you have asserted that calls to the function can be bound at
compile time, the compiler can apply any assertions on the formal
parameters to the actual parameters and use type information derived
 from the definition as the type of the call result.

Early-binding of function names also allows many other optimizations
such as "inline expansion" and "block compilation".

Before people flame uncotrollably about the horror of static function
binding in Lisp, I will point out that I don't propose that static
function binding be required, or even that it necessarily be the
default.  It is also worth noting that the extent to which static
binding is actually done once it has been allowed is an implementation
decision.  Declaring static binding doesn't necessarily prevent
incremental redefintion or reduce safety, it might only cause better
compiler warnings to be generated.

If this capability exists, then function type declarations (and
function types) are more useless than they currently are (if that is
even possible).

  Rob

P.S.  My proposal is <ram>cprop.txt on c.cs.cmu.edu