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

Some notes about declarations



    Date: Tue, 11 Mar 86 17:48 EST
    From: Kent M Pitman <KMP@SCRC-STONY-BROOK.ARPA>

    Do we provide a way to type-declare functions (ie, FTYPE) that have
    &optional or &rest specifications? It seems like
     (FTYPE (FUNCTION (INTEGER &OPTIONAL INTEGER) FLOAT))
    would have been reasonable, but I can't find anything that suggests
    I can do this. &REST would be more complicated, but not prohibitively so.
    Am I missing something or do we not have a way to do this at all.

CLtL, page 47, 4 lines from bottom, make the offhand remark that the
&optional, &rest, and &key markers may appear in the list of argument
types, but unfortunately that bagbiter Steele failed to give any
examples.  Furthermore, &allow-other-keys ought to be allowed, because
that has an effect on the external user interface.

I believe this issue has been discussed before on this mailing list.
One problem is that for an &optional argument one can give just the type,
but for a &key argument one must write the keyword as well as the type,
as (:start (integer 0 ())), for example.

    Do we provide a way to declare that a function is n-ary (or not) at all? That
    is, the equivalent of the *EXPR and *LEXPR declarations in Maclisp? I guess
    I would be surprised if there was no CL implementation that could generate 
    better code in cases where I declared this kind of thing ahead of time.

Sure: to make it n-ary, say
	(DECLARE (FTYPE (FUNCTION (&REST T) T) APPEND))
to declare APPEND, for example.

    And while we're on the subject, is there some reason that PROCLAIM was
    not made to be n-ary?  It has bothered me on numerous occassions that I
    have to do:
     (PROCLAIM '(SPECIAL X))
     (PROCLAIM '(FIXNUM X))
    when we could just as well have allowed:
     (PROCLAIM '(SPECIAL X) '(FIXNUM X))
    Allowing multiple arguments would be more consistent with DECLARE.

No reason I know of.
--Guy