Aaron Sherman wrote:
Jonathan Lang wrote:
> 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) { ... } }

What would be the difference between this and

       role Foo { sub bar($baz) { ... } }

?  IOW, what's the difference between a 'sigform' declaration and a
"to be defined later" subroutine declaration?

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.

True enough.  That said, it wouldn't be hard to change this.  Consider
the possibility of an "exported" trait, which causes whatever it's
applied to to be exported whenever a module imports its package.
Thus, you could say something like:

       <start of file>
       role Foo;
           sub bar($baz) is exported { ... }

At which point anything that imports a module that composes Foo will
import bar as well.

And I'm making the (probably erroneous) assumption that Perl 6 doesn't
have a robust, intuitive means of marking package components for
export already.  I'm sure that a few moments with the appropriate
Synopsis would correct said error.

Jonathan "Dataweaver" Lang

Reply via email to