[racket] Small and short-lived data structures

From: Antonio Menezes Leitao (antonio.menezes.leitao at ist.utl.pt)
Date: Tue Oct 22 05:44:43 EDT 2013

On Mon, Oct 21, 2013 at 8:41 PM, Sam Tobin-Hochstadt <samth at cs.indiana.edu>
wrote:
> On Mon, Oct 21, 2013 at 3:36 PM, Neil Van Dyke <neil at neilvandyke.org>
wrote:
>> Sam Tobin-Hochstadt wrote at 10/21/2013 02:35 PM:
>>>
>>> https://gist.github.com/samth/7088570
>>>
>>
>> [...]
>>
>>> Direct is always fastest, multiple values are very slow, and cons is
>>> always slower than mcons.
>>
>>
>> Is there any relatively low-hanging fruit optimization that can be done
for
>> multiple-value returns in general?
>>
>> I'm not surprised that pairs are fast in this example, since pairs are
both
>> basic and have a special place in the history of Lisps.  But I like to
>> pretend that multiple-value returns in Racket are often optimized
(perhaps
>> to registers, but at least to not worse than using a pair or pairs).
>
> A little bit more smarts in the inliner/constant-folder could turn the
> multiple-values version of the code into the direct version of the
> code, I think.  But that wouldn't really address your question, since
> it's unlikely that most uses of multiple values are this immediately
> removable.

Just as an additional data point, my code shows a frequent use of
multiple-values in expressions of the form

(let-values ((foo bar)
               (if (test?)
                   (values 1 2)
                   (values 3 4)))
    ...)

It would be nice if this could be optimized.

Best,
António.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20131022/21dee07d/attachment.html>

Posted on the users mailing list.