On Friday, January 3, 2003, at 01:19 PM, Dave Whipp wrote:
I was under the impression that a more concise way of saying that would be:Conversly, an C<tie> operation should be nothing more than$obj = new ArrayLikeThing; @a := $obj; # the tie
my @a = new ArrayLikeThing;
-or-
my @a is ArrayLikeThing .= new;
Where ArrayLikeThing must inherit from, or at least present the same interface as, the built-in Array (array?) type. But that, in turn, should just be equiv to:
my @a is ArrayLikeThing;
Oof. There might be a big problem here. If we work backward from previously stated examples:
my int @a; # these should all be identical, right?
my @a returns int;
my @a is Array of int;
my @a is Array returns int;
my int @a is Array;
Here we're using "is" not as a property marker, but meaning "isa". These lines all declare @a to be an array that stores ints. That would imply that the "is Array" part is actually instantiating (C<new>ing) the array... you're not saying that @a "can someday hold an array obj", you're saying it already _is_ an array obj.
So we're using "is Blah" here as a method of creating an already-instantiated object, not just typing a variable(?) But that, in turn, would imply that:
my Foo $a; # declares $a as holding objects of type C<Foo>
my $a is Foo; # instantiates $a as a C<Foo>.
Oh dear. That looks quite wrong.
BUT we *need* to be able to explicitly say "is Array", or something like it, if we're to be able to easily make alternate implementations of arrays:
class MyArray is Array {
... stuff overriding the default behavior...
}
my @a is MyArray; # Boom! No C<tie> needed, ever!
or if we're to make complex constructs like:
my @a is Array of Array of Hash of str;
It also could be a cornerstone of classless OO:
my $obj is $parent;
So there appears to be either a flaw in my logic, in my syntax, or in something bigger. Given that p6d is supposed to start working on Arrays, I think we (or at least I) need some clarification...
MikeL