[CC'ed to language, because I think it's there that it belongs]

On Mon, 5 Feb 2001 15:35:18 -0200, Branden wrote:

>There are two possible things that could happen when you say:
>    $a = $b;
>    @a = @b;  # or
>    %a = %b;
>
>These two things are assignment and aliasing.

No way. Although I think aliasing is a great tool, but assignment is by
value. Always. (Well, except for referenced things...)

>In perl5 terms:
>    *a = \$b;
>    *a = \@b;  # or
>    *a = \%b;

>However, typeglobs are said to disappear from Perl6,

I think Larry wants to drop typeglobs themselves, i.e. keeping different
kinds of variables of the same name in one record, but not the
possibilities they offer. Aliasing is likely the most interesting
feature of them all.

...

My preference:

>* Alias when assigning to a reference:
>    \$a = \$b;
>    \@a = \@b;
>    \%a = \%b;

I think this is a nice symmetrical syntax.

>* Make aliasing the default for = and provide another way of assigning (NO
>WAY!!!)

Indeed, no way.

Look, if you'd do the latter, you would not only make Perl effectively a
different language, but you'd also be missing out on one of the great
benefits of aliasing. For example, you pass a reference of a hash to a
sub, so the original hash can be accessed and modified. With the latter
syntax, you can't even do that through an alias. In the former syntax:

        foo(\%bar);

        sub foo {
            my \%hash = shift;  # alias through reference
            print $hash{FOO};
        }

You can now access the passed hash as a hash, and not through the
slightly awkward syntax of accessing it through a reference:

        sub foo2 {
            my $hash = shift;
            print $hash->{FOO};
        }

(You don't think it's that awkward? Try getting a hash slice through a
hash reference. Ugh.)

-- 
        Bart.

Reply via email to