On Mon, 2013-07-29 at 09:13 -0400, Paul Khuong wrote:
> I recently had a sad insight into this: what does it mean when a
> function like
> (lambda () (let ((x (list 1 2 3))) (values x x)))
> is of type
> (function * (values (cons integer (cons integer (cons integer null)))
> cons &optional))?
Wouldn't that just say "The function returns exactly two values, the
first of which is of type (cons integer (cons integer (cons integer
null))) when it is returned and the second of which is of type cons when
it is returned". In my understanding, this is independent of the fact
whether the returned values are mutated later or share structure.
Of course, the example still ruins our scheme :(
> Our current machinery, with lvar-conservative-type (used in CAR and CDR
> derive-type and to determine array dimensions), already seems wrong here.
I don't see why. In a case like
(defun f () (let ((x (list 1 2))) (values x x)))
(declaim (ftype (function * (values (cons integer (cons integer null)) cons &rest nil)) f))
(defun (g) ()
(multiple-value-bind (x1 x2) (f)
(setf (car x2) #\a)
(+ (car x1) 1)))
LVAR-CONSERVATIVE-TYPE of X1 and X2 are both (cons t t) which doesn't
seem wrong to me.
> Is such aliasing disallowed by the type system?
Given that I didn't understand the previous points, I may be missing
something fundamental. That said, I don't see why it would be
disallowed. Sorry, if I'm missing something obvious.