At 07:44 PM 04-23-2001 +0100, Graham Barr wrote:
>Hm, I would expect @() in a scalar context to give the
>same result as
>
> @tmp = @(...); $x = @tmp;
>
>That is, yeild the number of elements in the list.
I can see this. But unless there is a good reason, that seems like a
less-than-optimal side-effect.
>What would be the benefit of it being the same as [...] ? It would be
>one more character.
I suspect that Larry is seeing that if @() in scalar context yielded the
length of the resulting operation would result in vastly more uses of:
$sums = [@(@a+@b)];
than
$num_of_sums = @(@a+@b);
If that's the case, then it makes sense to use the shorter notation for the
more common case, especially when there is an easy, shorter way to get the
uncommon case:
$sums = @(@a+@b);
$sumcount = \@(@a+@b);
# assuming that $sumcount = @a isn't sufficient.