Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re^11: can sub check context for lvalue vs rvalue context?by LanX (Saint) |
on May 11, 2018 at 17:02 UTC ( [id://1214393]=note: print w/replies, xml ) | Need Help?? |
I agree with both of you. Yes you are never returning a read only value. But as BUK demonstrated the caller could take a reference* and assign later. In this case your logic would break without a protecting tie. Anyway did you benchmark the impact of a tie? IIRC does a tied variable without FETCH method fall back to a normal read.° Not sure about the resulting performance penalty.
Cheers Rolf
*) Your WANTLVALUE would need reflect this too, like in an extra state "referenced". °) looks like I was confusing the semantics of Tie::Scalar (with a fallback method) with a normal perltie on scalars, where FETCH must be defined.
In Section
Seekers of Perl Wisdom
|
|