in reply to Doing "it" only once

I've had this type of thought running through my head relatively recently, but it wasn't nearly as well "defined" as this, nor did I pursue the idea as you have.

I think the problem is going to be the "negligible cost". Without unrolling the loop internally, you'd still be forced to evaluate an if, unrolling the loop adds complexity etc.

Thanks for the snippet anyway, whether or not it is actually worth the trouble, it's still a nice trick.

-Scott

Replies are listed 'Best First'.
Re^2: Doing "it" only once
by 5mi11er (Deacon) on Sep 22, 2005 at 14:42 UTC
    After spending nearly half of my votes on this thread this morning, I'd contemplated updating the node above; but I also wanted to further comment, thus I'm adding this node.

    When I originally replied above, optree modification had not entered my mind. However, that option is certainly no less complex than unrolling the loop. At first glance it seems like that optree modification might be the answer, but as the code example to do that by diotalevi shows, its not trivial.

    I think QM's post below is an excellent summary of this thread and the [good] ideas presented.

    -Scott