Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Private behavior in roles

4 views
Skip to first unread message

Ovid

unread,
Nov 17, 2005, 4:55:31 PM11/17/05
to perl6-l...@perl.org
In http://perlmonks.org/?node_id=509413 (in response to
http://perlmonks.org/?node_id=509256), Rob Kinyon wrote that in his
understanding of Perl 6 Roles, anything a role can do the class "doing"
the role should also be able to do.

Is this correct? I'm getting bitten with Class::Trait because some of
my traits import helper functions and constants from other packages.
The classes implementing the traits should *not* care about how the
trait does something, but those functions and constants are getting
flattened into my classes and this has been causing all sorts of
problems.

For the time being, I have rewritten all of my traits to not import
anything in the trait namespace, but I intend to modify Class trait so
each method can be defined thusly:

sub some_method : Public { ... }

In the original traits definition, as I understood them, a trait should
specify what it requires *and* what it provides. Are Perl 6 roles
really going to blindly export everything they contain? This seems a
serious mistake. I didn't see anything addressing this issue in
http://www.perl.com/pub/a/2004/04/16/a12.html?page=12

Cheers,
Ovid

--
If this message is a response to a question on a mailing list, please send
follow up questions to the list.

Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/

Larry Wall

unread,
Nov 19, 2005, 5:10:06 AM11/19/05
to perl6-l...@perl.org
On Thu, Nov 17, 2005 at 01:55:31PM -0800, Ovid wrote:
: In http://perlmonks.org/?node_id=509413 (in response to

: http://perlmonks.org/?node_id=509256), Rob Kinyon wrote that in his
: understanding of Perl 6 Roles, anything a role can do the class "doing"
: the role should also be able to do.
:
: Is this correct?

Only sorta. A role has its own lexical scope that the class is not
privy to, and lately we're trying to manage privacy via lexical scoping
as much as possible.

: I'm getting bitten with Class::Trait because some of


: my traits import helper functions and constants from other packages.
: The classes implementing the traits should *not* care about how the
: trait does something, but those functions and constants are getting
: flattened into my classes and this has been causing all sorts of
: problems.

In Perl 6 imports are lexical by default, so that shouldn't be a problem.

: For the time being, I have rewritten all of my traits to not import


: anything in the trait namespace, but I intend to modify Class trait so
: each method can be defined thusly:
:
: sub some_method : Public { ... }
:
: In the original traits definition, as I understood them, a trait should
: specify what it requires *and* what it provides. Are Perl 6 roles
: really going to blindly export everything they contain? This seems a
: serious mistake. I didn't see anything addressing this issue in
: http://www.perl.com/pub/a/2004/04/16/a12.html?page=12

Please don't rely on perl.com for the latest design docs. I just
checked in a new S12 to svn.perl.org a few minutes ago that hopefully
covers most of the questions raised here and on perlmonks. Doubtless
there will be more issues, but that's the nature of the beast.

I'll need to go and install some Update sections in A12, but bein's as
it's 2:00 in the morning I'm going to bed...

Larry

0 new messages