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

Question about declaration



    Date: Wed, 16 Dec 87 13:19 est
    From: mike%acorn@oak.lcs.mit.edu

	Date: Fri, 11 Dec 87 10:54 EST
	From: Robert W. Kerns <RWK@YUKON.SCRC.Symbolics.COM>
    
	    Date: Fri, 11 Dec 87 01:16 EST
	    From: Brad Miller <miller@ACORN.CS.ROCHESTER.EDU>
    
	    How would you write a function declaration for the following?
    
	    (defun foo (bar)
		(declare (type list bar))
		(values-list bar)
    
	    (proclaim '(function foo (list) ????))
    
	I wouldn't.  CL doesn't have any syntax for declaring
	a variable number of values, period.
    
    I think you can do this in CL:

    (function foo (list) (values &rest list))

    see CLtL pg 48 under the values type specifier. The explaination for
    this "feature" is motivated by multiple-value-call.

Yes, but you haven't really declared those values, have you?
All you've done is declare that you can have a "list of them".

Now, if there was a "sequence-enumerated" type (as we have
in our UIMS), this would be a different matter.  I.e.
(function foo ((and list (sequence-enumerated symbol integer symbol integer)))
	      (values &rest (and list (sequence-enumerated symbol integer symbol integer))))

    So presumably with this declaration, you can do

    (multiple-value-call '+ (foo 1 2 3))

    and get some kind of optimized call since it knows it's getting back
    a variable number of values when FOO returns.

    ...mike beckerle
    
But what you'd *like* to know here is that the individual elements are integers;
i.e.
(function foo ((list integer))
	      (values &rest (list integer)))

where the new argument to LIST does *NOT* work like ARRAY (meaning "a kind of
list specialized to contain only integers"), but rather means "a list whose
elements are all INTEGER's".

There is a big gap between being able to declare the existence of
a variable number of arguments or values and being able to declare
their type.