<div dir="ltr">On Mon, Oct 21, 2013 at 8:41 PM, Sam Tobin-<span class="" style>Hochstadt</span> <<a href="mailto:samth@cs.indiana.edu" target="_blank"><span class="" style>samth</span>@cs.<span class="" style>indiana</span>.<span class="" style>edu</span></a>> wrote:<br>
> On Mon, Oct 21, 2013 at 3:36 PM, Neil Van Dyke <<a href="mailto:neil@neilvandyke.org" target="_blank"><span class="" style>neil</span>@<span class="" style>neilvandyke</span>.org</a>> wrote:<br>
>> Sam Tobin-<span class="" style>Hochstadt</span> wrote at 10/21/2013 02:35 PM:<br>>>><br>>>> <a href="https://gist.github.com/samth/7088570" target="_blank">https://gist.<span class="" style>github</span>.com/<span class="" style>samth</span>/7088570</a><br>
>>><br>>><br>>> [...]<br>
>><br>>>> Direct is always fastest, multiple values are very slow, and cons is<br>>>> always slower than <span class="" style>mcons</span>.<br>>><br>>><br>>> Is there any relatively low-hanging fruit optimization that can be done for<br>
>> multiple-value returns in general?<br>>><br>>> I'm not surprised that pairs are fast in this example, since pairs are both<br>>> basic and have a special place in the history of Lisps. But I like to<br>
>> pretend that multiple-value returns in Racket are often optimized (perhaps<br>>> to registers, but at least to not worse than using a pair or pairs).<br>><br>> A little bit more smarts in the <span class="" style>inliner</span>/constant-folder could turn the<br>
> multiple-values version of the code into the direct version of the<br>> code, I think. But that wouldn't really address your question, since<br>> it's unlikely that most uses of multiple values are this immediately<br>
> removable.<br><div><br></div><div>Just as an additional data point, my code shows a frequent use of multiple-values in expressions of the form</div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">(let-values ((foo bar)</font></div>
<div><font face="courier new, monospace"> (if (test?)</font></div><div><font face="courier new, monospace"> (values 1 2)</font></div><div><font face="courier new, monospace"> (values 3 4)))</font></div>
<div><font face="courier new, monospace"> ...)</font></div><div><br></div><div>It would be nice if this could be optimized.</div><div><br></div><div>Best,</div><div><span class="" style>António</span>.</div><div><br></div>
</div>