in reply to Re^7: Tracking down an Lvalue bug?
in thread Tracking down an Lvalue bug?

ActivePerl 5.14.0 (32 bit) on Windows

Confirming that the behaviour is also changed on 64-bit 5.14 for windows.

There will be a memory increase if you read the string $$r, but that's how magic works in Perl.

I accept that is how it currently works, but question whether is should or has to work that way.

If the reference is only ever used for reading, duplicating the reference memory is a complete waste of time (cpu & memory).

At the very least it should be possible to defer the duplication until a mutating operation is performed upon it.

Even then, I question whether it is necessary to duplicate the substring, and then copy the modified version back over the original.

If a temporary SV* (be it a TARG or LVTARG or just a mortal SV* created for the purpose) was initialised so that its PV pointed directly at the original strings PV buffer, and it used the OOK trick, CUR & LEN to make that temporary SV* point to just the referenced substring in-place. And then that temp SV was passed to the mutating operator, everything should work as it would with a normal SV.

When the mutating operator completes, the PUT magic gets control and can fix up the original (referenced) Sv to reflect any changes.

But, I am aware that this is the kind of thing we could argue back forth, round & round and down a dozen blind alleys and never reach a conclusion. The only way to avoid that is to prove my theory. And that is going to take time.

I'm also currently working on a machine that has a dodgy motherboard and an increasingly frequent habit of blue screening at the slightest provocation. I have a new motherboard and ram on its way, but till then, I'm not getting into anything deep because of the risk of loosing code though random failures.

So bear with me. I'll either come back with proof of concept code or an acknowledgement that I couldn't make it work.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?