Daniel Ruoso wrote:
> Hi,
>
> As smop and mildew now support ControlExceptionReturn (see
> v6/mildew/t/return_function.t), an important question raised:
>
> sub plural { return 1,2 }
> sub singular { return 1 }
> my @a = plural();
> my $b = plural();
> my @c = singular();
> my $d = singular();
>
> What should @a, $b, @c and $d contain?
@a = 1, 2;
$b = [1, 2];
@c = 1;
$d = 1;
(According to DWIM semantics and my understanding of the specs)
> Note that the spec says explicitly that a Capture should be returned,
> delaying the context at which the value will be used, this allows
>
> sub named { return :x<1> }
> my $x := |(named);
>
> So, this also means that assigning
>
> my @a = plural();
> my @c = singular();
>
> forces list context in the capture, which should return all positional
> parameters, as expected. But
>
> my $b = plural();
> my $d = singular();
>
> would force item context in the capture, and here is the problem, as a
> capture in item context was supposed to return the invocant.
Maybe we could have a different rule for captures in scalar contexts
that don't have an invocant?
Just my 0.02€,
Moritz