Larry wrote:
: >  multi foo (@a is Array of int) {...}
: >
: >  my int @a = baz();     # is Array of int
: >  my     @b = baz();     # is Array of Scalar
: >
: >  foo(@a);    # @a is typed correctly, so OK
: >  foo(@b);    # @b is not explicitly typed as C<int>; OK or FAIL?
<snip>
I dunno. I can argue that it should coerce that.

Damian wrote:
Hmmmm.

I think that IF there's a significant speed issue there at all, it should just fail. (IMO, it's more important to be able to optimize for speed.) But the issue is of course that when people make temporary arrays, I imagine they'll seldom be explicitly typed, because we all like to be lazy slobs:


sub baz returns Array of int {...}

my @temp = baz();

Since this is such a common case, it might be possible to leave a lazy 'hint' after the assignment such that @temp is treated as an C<Array of int>, because we know for a fact that's how it was (last) assigned. The next operation on @temp would clear the hint:

push @temp, $i; # well, now we don't know *what* type @temp returns


(I hate to niggle at all over such a stupid little edge case, but I worry it's going to be terribly common.)


MikeL

P.S. I'm so happy I'm getting my multimethod-friendly Array of Array of Cats! Herding Cats is so much easier when they're placed in explicitly typed multidimensional buckets!



Reply via email to