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

Current practice:argument types in function declarations

    From: masinter.PA@Xerox.COM
    Date: 16 Dec 87 1:32:02 PST
>Is anyone aware of any (released? supported?) Common Lisp implementation that
>pays any attention at all to the types of arguments, e.g., for which
>    (proclaim '(function my-function (list vector) t))
>has any effect different from
>    (proclaim '(function my-function (t t) t))
>    ?
>Does anyone *have* any Common Lisp code which contains such declarations?
>What is the intent of the declarations, other than as documentation?

First off, either signature tells you more than nothing at all, since
it fixes the number of arguments. Presumably, you have to check
the number of arguments as well as the types for really safe calls.

As for use, we are not using them currently, but plan to use them.
The goal is to generate "safe" calls for functions when compiling if
the type signature is unknown. If the type signature is known;
however, the checking burden is placed on the caller (and can be
minimized via type inference, etc.) and an unsafe call is generated.
The type signature can be known either via block compilation, or
by using function type proclamations. In any case if you ftype a function
and a call can be shown to contradict the proclamation, then you
should get a warning and a safe (slow) call.

The one difficulty with these things is that common lisp's type
language doesn't allow you to specify accurate types for things 
like <. E.G.,

(proclaim '(ftype < (function (&rest ??) (or T nil))))

For ?? you'd like to say "zero or more non-complex numbers". You do 
NOT want to say LIST here.

I am considering defining a (list-of ...) type specifier.
where the argument is a type. This cannot really be written in 
common lisp, since it doesn't allow parameterized types in general.
But we as implementors can put it in place as an extension.

Mike Beckerle
Gold Hill Computers.