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


Seems to me that we're trying to overload the type definition for
FUNCTION in ways that are not altogether consistent.  I'd suggest the

1. Leave the FUNCTION type specifier alone.  It's not terribly useful in
its non-restrictive form, but it is harmless and it does fit in with the
rest of the type system.  (Of course, we would make it a full-fledged
type-specifier as discussed in the FUNCTION-TYPE proposal.)

2. Add an extended form for the LIST type specifier so that one can
indicate element type and, perhaps, length.  This can be used to say
something useful about rest-args, without having to put in ugly special
syntax for this.

3. Add a new declaration/proclamation, distinct from TYPE, by which
users can tell the compiler restrictive things about what a given
function will accept and what it will return.  This notation can be set
up so that you can say things like "if all args are integer, the result
will be" and "if the second arg is spaceship, the result will be
Martian".  Obviously this bit will require some careful design so that
we can make it maximally expressive and minimally confusing.  I don't
have a proposal ready; maybe Rob does.

4. Let me toss in here a related idea by Dave Touretzky that I've been
waiting to introduce whenever the time is right for a new batch of
issues: the RESTRICT declaration/proclamation.  Basically, (DECLARE
(RESTRICT type1 type2)) says that, within the extent covered by this
declaration, anything that is of type1 is guaranteed to be of type2 as
well, where type2 is generally more restrictive.  One could say
(RESTRICT NUMBER (INTEGER -1024 1024)), which tells the compiler that
any time it can prove something is a number, it can assume it is a
fixnum.  In some contexts, this can replace about six dozen THE
forms.  Users find it very awkward to say things like

(the (integer -1024 1024) (+ (the (integer -1024 1024) x)
                             (the (integer -1024 1024) y))

..yet often that is the only portable way to assure the compiler that it
can generate fixnum-only code on most machines.

The reson I bring up RESTRICT at this time is that I think the function
restriction mentioned in point 3 is related to this.  Maybe it should be
called RESTRICT-CALL or something.

-- Scott