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

Re: [Scheme-reports] multiple values module

9 hours ago, John Cowan wrote:
> Andy Wingo scripsit:
> > What's the rationale for breaking call-with-values and values out to
> > their own module?
> Primarily because they aren't in IEEE/R4RS.


> > Suggestion: since it is trivial to implement `call-with-values'
> > with a define-record-type <values>, simply require it in the base
> > Scheme.  [...]

IMO implementations that do some half-baked reification of multiple
values as first-class values are broken.  Things like
(list (values 1 2) 3) or (define x (values 1 2)) should throw an
error.  (Note to potential flamers: this has nothing to do with the
question of having MV in the language.)

One relevant by-product of this is that debating whether `set!' can
return 0 values looks very different in such an implementation.

> Chibi actually implements multiple purely in Scheme by returning a
> list with a unique CAR, which prints as "(value)".

Ugh.  If the above is broken, then this is a train wreck.

  > (cadr (values 1 2))
  > (length (values '(1) 2))
  > (define (foo x)
      ;; this function always returns 3...?
      (length (call-with-values (lambda () (list x 1 2)) list)))
  > (foo (car (values)))

I'm sure that there are reasons for implementing things this way, but
making an argument out of it sounds insane.  (Or a camouflaged attemt
to make multiple values so useless that it's as if they're not in...)

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Scheme-reports mailing list