Re: Runtime role issues

2006-10-12 Thread Aaron Sherman
Ovid wrote: The "intermediate class" solves the problem but it instantly suggests that we have a new "design pattern" we have to remember. Basically, if I can't lexically scope the additional behavior a role offers, I potentially need to remove the role or use the "intermediate class" pattern.

Re: Runtime role issues

2006-10-12 Thread Larry Wall
On Thu, Oct 12, 2006 at 09:27:53AM -0700, Jonathan Lang wrote: : To modify a class at runtime, use C. C is compile time. You'd have to eval it. Larry

Re: Runtime role issues

2006-10-12 Thread Jonathan Lang
Miroslav Silovic wrote: Paul Seamons wrote: > > On closer inspection, is it even possible to add a Role to a Class at > runtime? > If it isn't now, I would certainly like to have a hook available through MOP (which is, to the best of my knowledge, still unspecified). To modify a class at runti

Re: Runtime role issues

2006-10-12 Thread Miroslav Silovic
Paul Seamons wrote: On closer inspection, is it even possible to add a Role to a Class at runtime? If it isn't now, I would certainly like to have a hook available through MOP (which is, to the best of my knowledge, still unspecified). I thought that Class and Role composition outside

Re: Runtime Role Issues

2006-10-12 Thread Audrey Tang
在 Oct 12, 2006 2:39 PM 時,Ovid 寫到: --To forcefully add a role to a class at a distance during runtime, use a class object call (see Moose::Meta::Class for more about these APIs): ^Dog.add_role(^Catlike); That's more of what I was thinking, but where is this documented? I can't find

Re: Runtime Role Issues

2006-10-11 Thread Ovid
--- Audrey Tang <[EMAIL PROTECTED]> wrote: > > I always thought when a role is applied to a class at runtime you > > get a new (anonymous) subclass. The original class isn't affected. > > Right, that's what usually happens with: > > my Dog $fido .= new; > $fido does Catlike; Am I miss

Re: Runtime Role Issues

2006-10-11 Thread Audrey Tang
在 Oct 12, 2006 5:43 AM 時,Tim Bunce 寫到: On Tue, Oct 10, 2006 at 01:31:59PM -0700, Ovid wrote: Hi all, In doing a bit of work with traits (roles) in Perl 5 (http://perlmonks.org/?node_id=577477), I've realized some edge cases which could be problematic. First, when a role is applied to a class

Re: Runtime Role Issues

2006-10-11 Thread Tim Bunce
On Tue, Oct 10, 2006 at 01:31:59PM -0700, Ovid wrote: > Hi all, > > In doing a bit of work with traits (roles) in Perl 5 > (http://perlmonks.org/?node_id=577477), I've realized some edge cases > which could be problematic. > > First, when a role is applied to a class at runtime, a instance of tha

Re: Runtime role issues

2006-10-11 Thread Ovid
--- TSa <[EMAIL PROTECTED]> wrote: > > First, when a role is applied to a class at runtime, a instance of > > that class in another scope may specifically *not* want that role. > > Is there a way of restricting a role to a particular lexical scope > > short of applying that role to instances instea

Re: Runtime role issues

2006-10-11 Thread Paul Seamons
> First, when a role is applied to a class at runtime, a instance of that > class in another scope may specifically *not* want that role. Is there a > way of restricting a role to a particular lexical scope short of applying > that role to instances instead of classes? Seems like you could use an

Re: Runtime role issues

2006-10-11 Thread TSa
HaloO, Ovid wrote: First, when a role is applied to a class at runtime, a instance of that class in another scope may specifically *not* want that role. Is there a way of restricting a role to a particular lexical scope short of applying that role to instances instead of classes? I think you'l

Re: Runtime role issues

2006-10-11 Thread TSa
HaloO, Ovid wrote: Third, http://dev.perl.org/perl6/doc/design/syn/S12.html says: You can also mixin a precomposed set of roles: $fido does Sentry | Tricks | TailChasing | Scratch; Should that be the following? $fido does Sentry & Tricks & TailChasing & Scratch; If you follow my

Runtime role issues

2006-10-11 Thread Ovid
Hi all, I posted this to Perl6 users, but I was Warnocked, it was the wrong list, or both. Here's another stab at it. In doing a bit of work with traits (roles) in Perl 5 (http://perlmonks.org/?node_id=577477), I've realized some edge cases which could be problematic. First, when a role is a

Runtime Role Issues

2006-10-10 Thread Ovid
Hi all, In doing a bit of work with traits (roles) in Perl 5 (http://perlmonks.org/?node_id=577477), I've realized some edge cases which could be problematic. First, when a role is applied to a class at runtime, a instance of that class in another scope may specifically *not* want that role. Is