Re: [Scheme-reports] multiple values module Eli Barzilay (20 May 2011 07:08 UTC)
Re: [Scheme-reports] multiple values module John Cowan (20 May 2011 16:02 UTC)
Re: [Scheme-reports] multiple values module Andy Wingo (20 May 2011 16:04 UTC)
Re: [Scheme-reports] multiple values module John Cowan (20 May 2011 19:48 UTC)
Re: [Scheme-reports] multiple values module Eli Barzilay (20 May 2011 19:50 UTC)
Re: [Scheme-reports] multiple values module Emmanuel Medernach (21 May 2011 06:43 UTC)
Re: [Scheme-reports] multiple values module Andy Wingo (21 May 2011 08:49 UTC)
Re: [Scheme-reports] multiple values module John Cowan (21 May 2011 17:50 UTC)
Re: [Scheme-reports] multiple values module Andy Wingo (22 May 2011 14:05 UTC)
Re: [Scheme-reports] multiple values module Emmanuel Medernach (24 May 2011 07:06 UTC)
Re: [Scheme-reports] multiple values module John Cowan (24 May 2011 16:08 UTC)
Re: [Scheme-reports] multiple values module Emmanuel Medernach (24 May 2011 17:06 UTC)
Re: [Scheme-reports] multiple values module Aaron W. Hsu (24 May 2011 18:54 UTC)
Re: [Scheme-reports] multiple values module Per Bothner (24 May 2011 23:26 UTC)
Re: [Scheme-reports] multiple values module John Cowan (24 May 2011 21:20 UTC)
Re: [Scheme-reports] multiple values module Eli Barzilay (24 May 2011 21:26 UTC)
Re: [Scheme-reports] multiple values module John Cowan (24 May 2011 21:37 UTC)
Re: [Scheme-reports] multiple values module Eli Barzilay (24 May 2011 21:41 UTC)
Re: [Scheme-reports] multiple values module Aaron W. Hsu (25 May 2011 03:41 UTC)
Re: [Scheme-reports] multiple values module Eli Barzilay (25 May 2011 06:42 UTC)
Re: [Scheme-reports] multiple values module Andy Wingo (21 May 2011 08:42 UTC)
Re: [Scheme-reports] multiple values module Aaron W. Hsu (20 May 2011 16:27 UTC)
Re: [Scheme-reports] multiple values module Alex Shinn (20 May 2011 16:54 UTC)
Re: [Scheme-reports] multiple values module Andy Wingo (20 May 2011 16:57 UTC)
Re: [Scheme-reports] multiple values module Eli Barzilay (20 May 2011 17:47 UTC)
Re: [Scheme-reports] multiple values module John Cowan (20 May 2011 20:38 UTC)
Re: [Scheme-reports] multiple values module Eli Barzilay (21 May 2011 02:03 UTC)
Re: [Scheme-reports] multiple values module John Cowan (21 May 2011 05:11 UTC)
Re: [Scheme-reports] multiple values module Eli Barzilay (21 May 2011 05:04 UTC)
Re: [Scheme-reports] multiple values module John Cowan (21 May 2011 18:43 UTC)
Re: [Scheme-reports] multiple values module Andre van Tonder (21 May 2011 19:49 UTC)
Re: [Scheme-reports] multiple values module John Cowan (21 May 2011 20:49 UTC)

Re: [Scheme-reports] multiple values module Aaron W. Hsu 25 May 2011 03:41 UTC

On Tue, 24 May 2011 17:41:14 -0400, Eli Barzilay <eli@barzilay.org> wrote:

>> What I meant was this: trivially any procedure that returns
>> multiple values could as well return a single value which is an
>> aggregate of some sort such as a list or general vector.  However,
>> it costs something to aggregate and disaggregate this value, a cost
>> which *some* implementations of multiple values need not pay.

> You can't avoid the extra cost.  Implementations vary with heap or
> stack allocation which is something that goes in a different level.
> In any case, your original statement of multiple values as some
> lightweight alternative is even more wrong given this.  (The
> historical context is first class continuations.)

I'm not sure what you mean by the above, but I believe what John is
referencing in the above is the efficiencies claimed by Ashley and
Dybvig's 1994 paper [1] with which I am relatively confident you are
familiar. The claim is that multiple values allows implementations to
efficiently pass values back to a continuation without incurring the cost
of explicit reification, which is what an implementation would normally
need to do without the multiple values interface. The example in the paper
uses split:

(define (split ls)
   (if (or (null? ls) (null? (cdr ls)))
       (values ls '())
       (let-values ([(odds evens) (split (cddr ls))])
         (values (cons (car ls) odds)
                 (cons (cadr ls) evens)))))

(define (split-cons ls)
   (if (or (null? ls) (null? (cdr ls)))
       (cons ls '())
       (let ([odds/evens (split-cons (cddr ls))])
         (cons (cons (car ls) (car odds/evens))
               (cons (cadr ls) (cdr odds/events))))))

In the implementation described by Ashley, which, according to the paper,
can be applied equally well to stack, heap, or CPS based compilers, the
split procedure above runs more quickly and with less allocation than the
split-cons version. John's point, I think, is that without a multiple
values interface in the language, reification is the normal means of
handling these situations. The CPS version of the above is also tested in
the paper and also benchmarked as slower and more space intensive than the
multiple values interface.

It should be noted, however, that the claim that multiple values are more
efficient in all cases, a claim that I do not think John is making, is
wrong, since even with the above mentioned implementation strategy, if the
compiler is not able to recognize certain things about the formulation,
the above speed gains will not be observed.

	Aaron W. Hsu

[1] "An efficient implementation of multiple return values in Scheme." J.
Michael Ashley and R. Kent Dybvig. 1994 ACM Conference on LISP and
Functional Programming, pp. 140-149, June 1994.
<http://www.cs.indiana.edu/~dyb/pubs/mrvs.pdf>.

--
Programming is just another word for the lost art of thinking.

_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports