Jonathan Lang wrote:
Aaron Sherman wrote:
TSa wrote:
> Miroslav Silovic wrote:
>> package Foo does FooMultiPrototypes {
>> ...
>> }
>
> I like this idea because it makes roles the central bearer of type
> information.
Type information is secondary to the proposal, but I'll run with what
you said.
This (the example, above) is a promise made by a class to meet its own
specification.
Actually, it's a promise made by a package (not a class) to meet the
specification given by a role (which can, and in this case probably
does, reside in a separate file - quite likely one heavily laced with
POD).
That's a fine thing to want to do. Not something that I was thinking of
initially, and only tangentially related, but a good idea. I think you
get this for free by embedding a proto (or perhaps a "sigform") inside
of a role:
role Foo { sigform bar($baz) { ... } }
Notice the lack of export which forces this to only apply to the class
or module to which the role is applied via composition, not to a module
which imports that class or module.
Whereas:
package CORE;
use Array;
use List;
...
=item max
=inline sigform max(@items, *%adverbs) is export {...}
...docs...
would not only impose those constraints on this use of Array and List,
but on the caller of CORE (in this case any typical Perl invocation).
Both work equally well, which is sort of nice, given that I didn't think
about the first form before-hand. I think that goes a long way to
demonstrate the flexibility of Perl 6's package/module/class/role system.