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 'struct-copy' 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'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'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'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>
><br>
> Would you need a "and is not a substruct?" predicate to make such things work?<br>
><br>
> Robby<br>
><br>
> On Mon, Aug 27, 2012 at 10:11 AM, Vincent St-Amour <<a href="javascript:;" onclick="_e(event, 'cvml', 'stamourv@ccs.neu.edu')">stamourv@ccs.neu.edu</a>> wrote:<br>
> > TR's complex number optimizations eliminate repeated boxing and unboxing<br>
> > in chains of operations that each consume and produce complex numbers.<br>
> ><br>
> > Similar optimizations for structs would eliminate structs for<br>
> > intermediate results in chains of operations that each consume and<br>
> > produce that same (single) kind of struct.<br>
> ><br>
> > If your code has such chains of operations, then these optimizations<br>
> > could apply.<br>
> ><br>
> > Do you have code that you think would benefit that I could look at?<br>
> ><br>
> > Vincent<br>
> ><br>
> ><br>
> > At Sat, 18 Aug 2012 12:40:21 -0600,<br>
> > Neil Toronto wrote:<br>
> >><br>
> >> Is TR's optimizer eventually going to unbox structs in the same way it<br>
> >> unboxes rectangular flonums?<br>
> >><br>
> >> I have a design choice right now: how to represent probabilities. Floats<br>
> >> are good because of their speed, but because of floating-point<br>
> >> limitations, *four different representations* are typically used. (For<br>
> >> the curious: p, 1-p, log(p), and log(1-p).) I'd like to make functions<br>
> >> that accept any one of these representations, denoted by this type:<br>
> >><br>
> >> (define-type Probability<br>
> >> (U probability 1-probability log-probability log-1-probability))<br>
> >><br>
> >> The types are simply struct types that tag Float.<br>
> >><br>
> >> Of course, manually boxing flonums ruins any chance of the compiler<br>
> >> emitting code that keeps the flonums unboxed. If TR's optimizer unboxed<br>
> >> structs, though, everything could be speedy.<br>
> >><br>
> >> FWIW, by "eventually," I mean "within the next n years", where "n" is a<br>
> >> smallish number.<br>
> >><br>
> >> Neil ⊥<br>
> >> _________________________<br>
> >> Racket Developers list:<br>
> >> <a href="http://lists.racket-lang.org/dev" target="_blank">http://lists.racket-lang.org/dev</a><br>
> ><br>
> > _________________________<br>
> > Racket Developers list:<br>
> > <a href="http://lists.racket-lang.org/dev" target="_blank">http://lists.racket-lang.org/dev</a><br>
</blockquote></div>