in reply to can sub check context for lvalue vs rvalue context?
It initially works but if you ever need to do validation on the setter you are lost.
use strict; use warnings; package Test; my $test; sub test :lvalue { return $test; } package main; Test->test =5; print Test->test; #> 5
Though there was a costly workaround by returning a tied value (from TheDamian IIRC) which catches the STORE.
Well, if you are willing to install XS, you could use Devel::Callsite to find and parse the OP-Tree.
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: can sub check context for lvalue vs rvalue context?
by perl-diddler (Chaplain) on May 09, 2018 at 03:12 UTC | |
by haukex (Archbishop) on May 09, 2018 at 08:37 UTC | |
by LanX (Saint) on May 09, 2018 at 10:43 UTC | |
by LanX (Saint) on May 09, 2018 at 06:54 UTC | |
by LanX (Saint) on May 09, 2018 at 07:06 UTC | |
by perl-diddler (Chaplain) on May 10, 2018 at 06:24 UTC |