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
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Wikisyntax for the Monastery
*) 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 reply to Re^11: can sub check context for lvalue vs rvalue context?
by LanX
in thread can sub check context for lvalue vs rvalue context?
by perl-diddler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |