On 2008 May 3, at 6:25, Richard Hainsworth wrote:
- if u want to add a role to an existing object, perl wraps the object into a class, adds the role, reinstantiates the object.
As I understand it, Perl inserts a new anonymous class as the object's parent, and adds the role to that. The object isn't reinstantiated or otherwise modified, just reparented.
As for the assertion in the subject: one could conceptually see a class being composed of a "role part" and a "class part". Using the object as a role would invoke only the "role part". (I would prefer some kind of indication that this is intended, e.g. a cast or maybe an adverb selecting the role.)
It seems to me that the jargon of 'inheritance' normally applied to a relation between objects and classes is misplaced in perl6. It is rather classes 'inherit' roles (like animals inherit genes from parents). Objects emerge as
You're just using the wrong model, I think. You need to look at the Smalltalk/OREXX/Ruby mixin model, in which you can mix new parents into individual objects; not the C++/Java model where an object has a fixed class that defines its "shape" and any inheritance must be done as part of that class or its superclasses.
-- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED] system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED] electrical and computer engineering, carnegie mellon university KF8NH