Jon Lang wrote:
> Larry Wall wrote:
>> Moritz Lenz wrote:
>> : Either it's parsed as '@a[0] = (W, W)' (list assignment), then @a should
>> : get both elements, and so should @z.
>>
>> Not according to S03, at least by one reading.  @a[0] as a scalar
>> container only wants one item, so it only takes the first item off
>> the list, and the list assignment produces a warning on the second
>> because it's discarded.  Since an assignment returns its left side,
>> only one element is available to @z from @a[0].
> 
> So, do we still have p5's 'want_array' (or whatever it was called)?

No.

> That is, the predicate that tells the you whether the function is
> being called in item or list context?  I know that the generalized
> 'want' function proved to be unworkable; but I'd expect p6 to at least
> be able to do everything that p5 can do; and that includes functions
> that are aware of whether they're being used as singular or plural.

The problem is that it's impossible in Perl 6, because we have multi
dispatch.

Consider this simple case:

multi a(@a*)    {  } # provides list context onto the arguments
multi a(Str $x) {  } # provides Str context or at least some sort of
                     # item context on the argument
sub b() { }
a(b());              # you can't know which context b() is called in

since the multi dispatch to a() depends on the return value of b(), we
only know b()'s context after we know its return value - which is too late.

So the "active" context propagation that Perl 5 does is not possible in
Perl 6.

Cheers,
Moritz

Reply via email to