On Fri, Jul 30, 2010 at 6:21 PM, R. Dresens <chrom...@nedlinux.nl> wrote:
> Yes, but aren't captures somehow replacements for references in
> general... and therefore also array references? The reason why I
> assume that is that I (wrongly?) expected a "real" 'Array()' when I
> used the `\` prefix in an expression such as `...@x`. �...@x` is an
> array, but ` \...@x` has become a 'Capture()' in recent rakudo
> releases, not an 'Array()' anymore. Hence my assumption.
Captures in Perl 6 are needed much less than references in Perl 5.
That's a feature, not a bug. References often make things more
confusing that they should be. You shouldn't need captures in most
Perl 6 code.

> ...but an "anoymous array" (if I may call it that?) assigned to `$x`
> is still an 'Array()'. So I'm really confused about the
> intricate difference between...
>
>    my $x = [1, 2, 3]
>
> ...and...
>
>    my @y = (1, 2, 3); my $x = \...@y

The latter should be written as

my @y = (1, 2, 3); my $x = @y;

Yeah, that requires some unlearning of Perl 5 idioms. $x and @Y are
indeed mostly the same, except that @y acts listy and $x not.

> ...apart from the question whether it has really an impact on
> practical code. I'm more or less trying to create a model of perl 6
> in my mind right now, and I really wonder how to explain this
> behavior.

I think the crucial step it to stop thinking you need the \ operator
for anything until you really need it.

Leon

Reply via email to