I think this may be another case of "it depends on what the word 'object' means", e.g. we're talking past each other. I hope.

Let's operate from the assumption -- or somebody please CORRECT ME IF I'M WRONG -- that the following syntax is valid:

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? 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.

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.

Now, what that looks like in Parrot I have no idea. But I'm assuming those all will work in P6, because (again, correct me if I'm wrong) Larry has stated they will.

Is there ANY QUESTION about ANY of that? If so, please let me know NOW, because the documentation group will writing up the 'Array' and 'Hash' sections in the coming weeks.

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;

It would seem remarkable if you *couldn't*, right? BUT, that's pointing out something that might be unexpected... it's actually instantiating a MyArray object for @a, without you having to do it yourself. Or it's marking that @a will be instantiated upon first use. The same thing happens when you say C<my @a is Array>, or even just C<my @a> -- it's fundamental to the syntax.

And that would imply you can do the same for hashes, and even scalars. Including arbitrary objects, yes?

my $a is Scalar; # long way of saying C<my $a>
my $a is int;
my $a is Scalar of int; # long way of saying C<my int $a>?
my $a is Scalar returns int; # long way of saying C<my int $a>?

my $a is MyClass; # works for anything
my $a is MyClass('a','b','c'); # so is this OK too?

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.

There's a lot of implications here, but it seems self-consistent, based on sound fundamentals, and all of it seems to be either directly stated or strongly implied by previous A's and E's and p6l threads. PLEASE tell me if/where I'm wrong here, ASAP.

MikeL

Reply via email to