in reply to Re: [Perl 6] $ and @ - what is it coming to?
in thread [Perl 6] $ and @ - what is it coming to?

Sigils serve two purposes: visual distinction, and name disambiguation (%foo is a different variable than @foo).

Automatic dereferencing doesn't impact any of those.

I'm not convinced. What if an Object is a collection class of some kind? And it only is useful on the top-level, as anything already inside another collection is a scalar.

—John
Writing from Pudong Airport

  • Comment on Re^2: [Perl 6] $ and @ - what is it coming to?

Replies are listed 'Best First'.
Re^3: [Perl 6] $ and @ - what is it coming to?
by moritz (Cardinal) on Mar 31, 2008 at 08:57 UTC
    What if an Object is a collection class of some kind?
    Could you elaborate on why this is could be a problem?
      The object might be "plural" to your mind, but is accessed via the object syntax $x.foo rather than being a @-sigil list variable.

      Upon further reading, I understand that @ variables can be bound at compile-time to any class that supports the Positional role. Though I think that can lead to subtle issues as well, such as losing the class when doing assignment.

      —John

        Though I think that can lead to subtle issues as well, such as losing the class when doing assignment.

        Uhm, you lose the type of scalar as well if you assign to the variable that holds it.

        my $a = 'Foo'; # $a isa Str now $a = 42; # $a isa Int now

        You're just used to dealing with it with scalars

        my @list = CustomList.new(); @list = @other_list; # you lose @list's type as well # assignment that preservers the type has to # assign to the contents, not the container: @list[*] = @other_list;