In A6, it is confirmed that you can have "complex" types such as:

my %pet is Hash of Array of Array of Hash of Array of Cat;

It is also confirmed that you can indeed use such types in sub signatures, e.g.:

sub foo (@a is Array of int) {...}


Confirmations/Questions:


1) Complex types for sub parameters: The above would imply that a sub can tell the difference between an C<Array of int> vs an C<Array of str>, thank goodness. That also implies that you can use arbitrarily complex types, and still get the same type checking:

sub foo ( %pet is Hash of Array of Array of Hash of Array of Cat ) {...}

Yes/No?


2) Multimethod dispatch: The text would seem to _IMPLY_ that you can perform multimethod dispatch based on complex types, but it isn't actually stated anywhere AFAICT. e.g.


  multi foo (@a is Array of str) {...}
  multi foo (@a is Array of int) {...}

... is it legal, and DWYM?


3) The edge point between explicitly typed and explicitly non-typed variables: If you pass an "untyped" array (or list?) to an explicitly typed array parameter, is the "untyped" array considered a unique case, or will it fail?


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?


MikeL




Reply via email to