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

What if an Object is a collection class of some kind?
Could you elaborate on why this is could be a problem?
  • Comment on Re^3: [Perl 6] $ and @ - what is it coming to?

Replies are listed 'Best First'.
Re^4: [Perl 6] $ and @ - what is it coming to?
by John M. Dlugosz (Monsignor) on Mar 31, 2008 at 09:50 UTC
    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;