Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: can sub check context for lvalue vs rvalue context?

by haukex (Archbishop)
on May 09, 2018 at 08:37 UTC ( [id://1214261]=note: print w/replies, xml ) Need Help??


in reply to Re^2: can sub check context for lvalue vs rvalue context?
in thread can sub check context for lvalue vs rvalue context?

Of course if you want to do something contingent on value change...then it seems perl only offers a tied-type solution.

The documentation Lvalue subroutines does make a reference to Sentinel, which, from a quick look at the docs, appears to implement something like a tied scalar, in XS.

The tied scalar solution appears to already have been implemented with Sub::Lvalue, and in fact a search for "lvalue" on CPAN will show that the wheel has been reinvented several times, including making object accessors lvalues. One of the most comprehensive ones appears to be Contextual::Return (which implements its LVALUE/RVALUE blocks using tied scalars, too).

Replies are listed 'Best First'.
Re^4: can sub check context for lvalue vs rvalue context?
by LanX (Saint) on May 09, 2018 at 10:43 UTC
    The perldocs mention Sentinel?

    Now I'm considering writing a POD differ who shows me all perldoc differences for new versions once per year... ;-)

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1214261]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-24 22:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found