in reply to Perl6 - value vs. reference issues

I've been making a nuisance of myself on this issue now and then. My impression is that explicit references will be gone, that they will be just the same, that they will do what I mean, and that I'm not supposed to worry my head about it.

That does make me worry.

After Compline,
Zaxo

Replies are listed 'Best First'.
Perl6: same great references, new improved syntax
by blssu (Pilgrim) on Sep 14, 2002 at 13:42 UTC

    Perl 6 still has references -- you can still take an explicit reference like \@array. However, Perl 6 will automatically take a reference or dereference a reference depending on context. Here are a few examples of Perl 6 with the Perl 5 in the comment.

    my %x = ( a => 1 ); # same my $y = %x; # $y = \%x %x{a} = 1; # $x{a} = 1 $y{a} = 1; # $y->{a} = 1
    This can surprise a Perl 5 veteran because the code $length = @array won't work the same anymore. (This is a good thing for beginning Perl 6 programmers though!)

    However, Perl 6 has more contexts than Perl 5 -- numeric and boolean contexts -- so some Perl 5 idioms still work. For example, if (@array) ... still works because the 'if' uses boolean context. $length = @array + 0 works because '+' uses numeric context.

    Of course, arrays are now objects, so the simplest way to get the length of an array is @array.length.

    For more information about variables in Perl 6 check out Apocalypse 2.