develooper Front page | perl.perl6.language | Postings from March 2005

Decorating Objects with Roles (was Re: Optional binding)

Thread Previous | Thread Next
From:
chromatic
Date:
March 8, 2005 15:23
Subject:
Decorating Objects with Roles (was Re: Optional binding)
Message ID:
1110324194.14806.75.camel@localhost
On Mon, 2005-03-07 at 19:40 -0800, Larry Wall wrote:

> On Mon, Mar 07, 2005 at 05:56:12PM -0800, David Storrs wrote:

> : Actually, I guess they would have to be...can you apply a role to a
> : bare type?
> : 
> :      my int does SelectOutputFile;  # I would expect this to fail 
> :      my Int does SelectOutputFile;  # I would expect this to work

> The latter always works.  The former can probably be made to work in
> the case of roles that only add methods and don't change the storage
> representation, since the vtable is associated with the class and
> not the object.

I could make the argument that it should be possible to decorate an
object with a role.  If that means generating a new anonymous class just
to have a vtable to munge, so be it.

-- c


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About