Michael Lazzaro wrote:

my int @a;
my @a returns int;
my @a is Array of int;
my @a is Array returns int;
my int @a is Array;

Those lines are all absolutely synonymous, and all declare an array of integers, right?
Right. (This week, at least ;-)


Likewise, Arrays have methods:

   my int @a = (1..100);
   print @a.length;               # prints "100"
   my @b = @a.grep { $_ > 50 };   # gets 51..100

... which is also known, based on previous Apocalypsii.
Right.


If we accept those as valid syntax -- and I *think* they have been -- then P6 Arrays are objects. Or, at minimum, they cannot be _discerned_ from objects, regardless of implementation.
The later, I strongly suspect.


The remaining big question, then, is whether you can truly subclass Array to achieve C<tie>-like behavior:

class MyArray is Array { ... };

my @a is MyArray;
Oh yes, I would certainly expect that this has to be possible.



Which, in turn, implies that the lines:

my Foo $a; # (1)
my $a is Foo; # (2)
my Foo $a is Foo; # (3)

are all subtly different. (2) and (3) (auto)instantiate a Foo, but (1) does not.
Correct. Though the instantiated Foo is the "implementation object" and
not directly accessible (just as the implementation object in a Perl 5
tie isn't).

BTW, C<my Foo $a is Foo> is just sick!
(i.e. I'll *definitely* be using it ;-)

Damian



Reply via email to