[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gls@AQUINAS/cc
Multiple Values
I wrote the SEUS compiler for the HP300 (?) version of SEUS. SEUS had
what-I-guess-are-now-called CARTs, which are coalescing multiple values.
Whenever 2 CARTs came near each other, they joined into one larger
one. This resulted in this code
(defun foo (x) (values x x x))
(defun bar (x)(values x x x x))
(list (foo 1)(bar 2)(foo 3))
doing this
=> (1 1 1 2 2 2 2 3 3 3)
The code, as Steele mentions, was elegant in a certain sense, but very
hard to read most of the time, because you had to take into account that
some other values than the primary value (the first one) would be passed
to some program. The places where SEUS code was easy to read were when you
were writing something that, in Common Lisp, would be
(multiple-value-call #'foo (baz)(bar))
The places where it was hard to read were when you were writing something
that, in Common Lisp, would be
(foo (baz) (bar))
That is, there was no easy way to check that the right values from the
right places got passed. I think that the latter is the more commonly
used case, so SEUS was optimized the wrong way.
It was hard to do this:
(defun foo (x)(values x (+ x 1) (+ x 2)))
(defun baz (x y) ...)
such that calling BAZ on (FOO 1) and (FOO 2) passed 1 and 2 to BAZ.
I recall that SEUS had no way to do this until I was half-way through
writing the compiler. I also recall that variables could be bound to
CARTs, somehow, as part of the solution to the problem - that is,
you could get X to be bound to the CART, [1 2 3], and Y to [2 3 4].
When the Common Lisp multiple value scheme was being devised, I thought
that we (the designers) should look at SEUS for its experience. I'm now
glad we didn't do anything more that invent MULTIPLE-VALUE-CALL as a
result of that experience.
-rpg-