Oh, okay. And so if you have a function that accepts a struct, does some work with it, and then returns a new version of it (and you wanted to optimize the body of the function), then you could get away with doing something like &#39;struct-copy&#39; to make the final version that gets returned.<div>
<br></div><div>Robby<br><br>On Monday, August 27, 2012, Vincent St-Amour  wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I don&#39;t think it would be necessary.<br>

<br>
For the optimization to trigger, the only thing a step in the chain can<br>
do with its argument is use its components. Anything else (e.g. checking<br>
whether it&#39;s a substruct) would require the argument to be boxed, and<br>
would prevent the optimization from happening.<br>
<br>
Each step of the chain is very limited in what it can do to its<br>
argument, which works fine for complex numbers (most operations on them<br>
only use the components), but I&#39;m not sure it would work well for<br>
structs.<br>
<br>
Vincent<br>
<br>
<br>
At Mon, 27 Aug 2012 10:15:04 -0500,<br>
Robby Findler wrote:<br>
&gt;<br>
&gt; Would you need a &quot;and is not a substruct?&quot; predicate to make such things work?<br>
&gt;<br>
&gt; Robby<br>
&gt;<br>
&gt; On Mon, Aug 27, 2012 at 10:11 AM, Vincent St-Amour &lt;<a href="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;stamourv@ccs.neu.edu&#39;)">stamourv@ccs.neu.edu</a>&gt; wrote:<br>
&gt; &gt; TR&#39;s complex number optimizations eliminate repeated boxing and unboxing<br>
&gt; &gt; in chains of operations that each consume and produce complex numbers.<br>
&gt; &gt;<br>
&gt; &gt; Similar optimizations for structs would eliminate structs for<br>
&gt; &gt; intermediate results in chains of operations that each consume and<br>
&gt; &gt; produce that same (single) kind of struct.<br>
&gt; &gt;<br>
&gt; &gt; If your code has such chains of operations, then these optimizations<br>
&gt; &gt; could apply.<br>
&gt; &gt;<br>
&gt; &gt; Do you have code that you think would benefit that I could look at?<br>
&gt; &gt;<br>
&gt; &gt; Vincent<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; At Sat, 18 Aug 2012 12:40:21 -0600,<br>
&gt; &gt; Neil Toronto wrote:<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Is TR&#39;s optimizer eventually going to unbox structs in the same way it<br>
&gt; &gt;&gt; unboxes rectangular flonums?<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; I have a design choice right now: how to represent probabilities. Floats<br>
&gt; &gt;&gt; are good because of their speed, but because of floating-point<br>
&gt; &gt;&gt; limitations, *four different representations* are typically used. (For<br>
&gt; &gt;&gt; the curious: p, 1-p, log(p), and log(1-p).) I&#39;d like to make functions<br>
&gt; &gt;&gt; that accept any one of these representations, denoted by this type:<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;    (define-type Probability<br>
&gt; &gt;&gt;      (U probability 1-probability log-probability log-1-probability))<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; The types are simply struct types that tag Float.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Of course, manually boxing flonums ruins any chance of the compiler<br>
&gt; &gt;&gt; emitting code that keeps the flonums unboxed. If TR&#39;s optimizer unboxed<br>
&gt; &gt;&gt; structs, though, everything could be speedy.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; FWIW, by &quot;eventually,&quot; I mean &quot;within the next n years&quot;, where &quot;n&quot; is a<br>
&gt; &gt;&gt; smallish number.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Neil ⊥<br>
&gt; &gt;&gt; _________________________<br>
&gt; &gt;&gt;   Racket Developers list:<br>
&gt; &gt;&gt;   <a href="http://lists.racket-lang.org/dev" target="_blank">http://lists.racket-lang.org/dev</a><br>
&gt; &gt;<br>
&gt; &gt; _________________________<br>
&gt; &gt;   Racket Developers list:<br>
&gt; &gt;   <a href="http://lists.racket-lang.org/dev" target="_blank">http://lists.racket-lang.org/dev</a><br>
</blockquote></div>