Chris Hostetter asked:
 
   > Quandary #1: How "deep" of type specifications should / will perl6 allow?
   > For example, could something like this work?
   >   my ARRAY(int(0..9)) $ref   # $ref can only store an array ref
   >                              # ...and that array can only hold ints
   >                              # ...and those ints must be between 0 & 9

I don't think that Perl 6 will have generalized type predicates like this.
More likely you will see a general (perhaps built-in, perhaps modular)
pre- and post-condition mechanism:

        sub small_int (int $val) { 0 <= $val <= 9 }

        my ARRAY $ref is pre(&small_int);


   > Quandary #2: Should / will subroutine prototyping provide any support
   > for specifying the return type?  perhaps...
   >   sub search (HASH $tree is rw, *@_) HASH { ...; return $tree }

Larry hasn't ever mentioned this. If it were to be implemented I would
imagine the syntax would be more like:

        sub HASH &search (HASH $tree is rw, *@_) HASH { ...; return $tree }


   > If so, this opens up all sorts of questions ... the influence of
   > calling context (ie: "wantarray") comes to mind.

That's 'want' in Perl 6. I imagine that return type and calling context
would remain largely orthogonal, except, of course, for compile-time messages
generated when they explicitly conflict:

        search($tree,$whatever).[2];    # Cannot use HASH reference as ARRAY!


   > Quandary #3: Should / will perl6 support polymorphic typing?

Probably. But that may require a more sophisticated type system than
most people would like to see (or implement!) in Perl. 

Damian

Reply via email to