Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Roles and functional programming

by stvn (Monsignor)
on Nov 26, 2008 at 21:21 UTC ( [id://726231]=note: print w/replies, xml ) Need Help??


in reply to Re: Roles and functional programming
in thread Roles and functional programming

Except that roles/traits compose and abstract/virtual classes still just inherit. The composition is the real win with traits/roles, without it they would be nothing more then ... uhm... abstract/virtual classes ;)

-stvn

Replies are listed 'Best First'.
Re^3: Roles and functional programming
by Bloodnok (Vicar) on Nov 27, 2008 at 11:29 UTC
    I think I must be missing the point stvn, I thought a class (in whatever language) was the composition of methods and/or data to model a behaviour.

    A user level that continues to overstate my experience :-))

      Yes, but there are different kinds of composition.

      With a class when you inherit from another class, it could be said you are "composing" the two classes together. In this type of composition (assuming everything is virtual methods), the subclass will "shadow" the superclass, but the superclass is still accessible to the subclass.

      With roles/traits the composition does not shadow but (via a set of rules) combine the two sets of methods/attributes into a new composite role/trait. In fact, after composition, the original roles can be discarded as all the nessecary info is now contained in the composite role. Also, because of the rules of composition, roles/traits are unordered, meaning you can compose the same set of roles/traits in arbitrary ways and still get the same composite trait in the end.

      -stvn
        TFT stvn, that's a whole lot clearer:-))

        A user level that continues to overstate my experience :-))

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://726231]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-16 11:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found