@x[0] = want(); # scalar context
@x[want()] = $_; # scalar context
@x[want()] = @_; # scalar context
@x[0,] = want(); # list context
@x[want(),] = $_; # list context
@x[want(),] = @_; # list context
$_ = @x[want()]; # scalar context
@_ = @x[want()]; # list context
Thanks,
/Autrijus/
Oh, and under the S02 rules above (the index expression inherits
outer context on RHS), Pugs currently does this:
$_ = %x{ 1, 2 }
--- reduces to ---
$_ = %x{ [1, 2] }
--- reduces to ---
$_ = %x{ "1 2" }
Which is, well, very surprising. Where did I get wrong?
Thanks,
/Autrijus/
I think allowing unknown LHS index expression to default to
scalar context is a bit more useful here. Since we have:
@x[0] = @y; # scalar
@x[0,] = @y; # list
This may be more intuitive:
@x[idx()] = @y; # scalar
@x[idx(),] = @y; # list
Than this:
@x[+idx()] = @y; # scalar
@x[idx()] = @y; # list
But I don't really feel strongly one way or another, as long
as it is specced down. :)
Thanks,
/Autrijus/
Good.
: @x[want()] = $_; # scalar context
: @x[want()] = @_; # scalar context
Maybe "unknown" context, which defaults to list.
: @x[0,] = want(); # list context
: @x[want(),] = $_; # list context
: @x[want(),] = @_; # list context
: $_ = @x[want()]; # scalar context
: @_ = @x[want()]; # list context
No, I think they're all list context.
Larry
I think S02 is probably wrong. It should be unknown/list context.
Sorry for the short answers, but I'm in Russia behind a flakey network
connection, which is probably going away entirely at any moment (the
network connection, not Russia.) I can clarify more next week when
I get back.
Larry
Okay. r2478 has them reverted to the original form, which
inspects the declared return type of want() to see if it is a subtype
of Scalar; if it is, then it is taken as scalar context;
otherwise (or if multiple multisubs are possible), it defaults
to list context.
Thanks,
/Autrijus/