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

Question on function type spec and lambda-list keywords

    Date: Mon, 3 Aug 87 12:39 EDT
    From: RpK%acorn@oak.lcs.mit.edu
    Is the ftype of +
      (function (&rest number) number)
      (function (&rest list) number)
    I would assume the former (since &rest args are always of type list), but
    there aren't any examples in CLtL that make this clear.

This seems a bit wierd, but I'd assume the latter, since

(function (&rest (list-of number)) number)

seems right.  Unfortunately, common lisp's type language doens't
allow parameterized types of this sort, so you can't really express this.
Other programming languages allow this sort of type construction.

You could do:

(deftype list-of-number ()
  `(satisfies list-of-number-p))

(defun list-of-number-p (x)
  (or (null x)
      (and (consp x)
           (numberp (car x))
           (list-of-number-p (cdr x))))


(proclaim '(ftype + (function (&rest list-of-number) number)))

since we're using "satisfies" here, I don't see how this could
be useful tho. 

...mike beckerle
Gold Hill