On Mon, Dec 06, 2004 at 05:43:16AM +0000, Nigel Sandever wrote:
: I probably missed teh comprehensive dismissal thread, but why not 'type'?
:
: my %pet is Hash[:type(Str) :returns(Cat)];
Well, "type" is just a little off in a couple of ways. On the one hand,
it's not specific enough, insofar as there are several different
types involved. On the other hand, it's too specific, insofar as what
you're specifying there is not a type, but something more like a signature,
albeit one without parameters. It's more like the attachment on a
multi to pick one of a set: &abs<complex>.
That says to me that what we're really looking at is
my Cat %pet is sig(Str);
my @matrix is sig(int where 0..3, int where 0..3);
where those might be abbreviated as:
my Cat %pet (Str);
my %matrix (3,3);
or
my Cat %pet .{Str};
my %matrix .[3;3];
or maybe even
my Cat %pet{Str};
my %matrix[3;3];
Which says that
my sub foo ($a) {...}
is maybe short for
my sub foo .($a) {...}
Hmm. Also says maybe you could attach a block to a hash or array to
define what subscripting does. Hmm.
Larry