Dan Sugalski wrote:
Substr should generate a new string and stick that into S0.Fine. But how do we know, which version we could take. Please read again Peter's example. It depends on the semantics of Sx register usage all over the program IMHO.
If we want to build a fast version that reuses a string register, I'm fine with that--it's definitely useful in a large number of circumstances, large enough to warrant expressing both sets of semantics.
My version doesn't break any current test but gives ~30% increase in life generations - yes I do know - 1): correctness, 2) speed - but what is correct for Peter's example?
The "normal" case would be that substr (or any operation resulting in a new Sx) should be able to reuse an existing string header. Peter's example is a of course valid but still exception from a normal program flow IMHO. If I (HL) want to save a SReg, I would copy (clone in PMC terms) it.
I think, we should invest some more thoughts on an optimization with that much potential in execution speed. DOD/GC runs aren't free, when minimized we can gain ~30% execution speed.
And for RL (or perl6) programs, reusign PMCs would be a similar case.
leo