in reply to Re^3: can sub check context for lvalue vs rvalue context?
in thread can sub check context for lvalue vs rvalue context?
The same type of situation already arises with "wantarray":
$x = do{ my @y = func() };
You could ask "well does sub get that it was called wanting an array or not?" Even though the assignment to the array is thrown away, it will will be called with wantarray=1; To say dual use subs should have been left as "experimental" because the end result is that only the scalar value is assigned to $x, is obviously not what has been done -- subs can return arrays or scalars based on 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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: can sub check context for lvalue vs rvalue context?
by BrowserUk (Patriarch) on May 10, 2018 at 07:19 UTC | |
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 ikegami (Patriarch) on May 11, 2018 at 19:51 UTC |