in reply to Re^4: can sub check context for lvalue vs rvalue context?
in thread can sub check context for lvalue vs rvalue context?
The same situation holds with the no-longer-experimental ':lvalue' subs. They just need the same treatment as dual-return subs returning scalar or array -- i.e. a keyword to let the sub know context.
(Part of) My point is that the caller can take a reference to whatever you return, and at some point later dereference that pointer and assign through it; with the expectation that the next time they call your sub, it will return the new value they've assigned; but taking a reference is explicitly an rvalue operation.
If you could detect the rvalue context and returned "a simple rvalue", you break that expectation.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: can sub check context for lvalue vs rvalue context?
by perl-diddler (Chaplain) on May 10, 2018 at 18:54 UTC | |
by BrowserUk (Patriarch) on May 10, 2018 at 19:28 UTC | |
by perl-diddler (Chaplain) on May 10, 2018 at 21:50 UTC | |
by BrowserUk (Patriarch) on May 10, 2018 at 22:51 UTC | |
by perl-diddler (Chaplain) on May 11, 2018 at 16:19 UTC | |
| |
by ikegami (Patriarch) on May 11, 2018 at 19:51 UTC |