in reply to Re^10: can sub check context for lvalue vs rvalue context?
in thread can sub check context for lvalue vs rvalue context?
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^12: can sub check context for lvalue vs rvalue context?
by perl-diddler (Chaplain) on May 14, 2018 at 03:53 UTC |