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.
In reply to Re^5: can sub check context for lvalue vs rvalue context?
by BrowserUk
in thread can sub check context for lvalue vs rvalue context?
by perl-diddler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |