Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: Roles and functional programming

by BrowserUk (Patriarch)
on Dec 01, 2008 at 22:54 UTC ( [id://727250]=note: print w/replies, xml ) Need Help??


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

Roles don't -have- attributes.

Hm. The quote was directly from Synopsis 12, so as far as the wording is concerned, you need to argue with the authors.

As far as the semantics are concerned, I did go on to say: "Of course, whatever state they have becomes a part of the instance into which they are composed", so I think we're in tune there.

But, as I also said, and regardless of whether the state is has'd by the Role, or provided by it, that state exists and is presumably usually affected by the Role and persists beyond the invocation of whatever methods the role also provides, so there is no sense in which it can reasonably be described as stateless.

If my limited understanding of ML's Functors means that they are like (my also limited understanding of) Haskell's Typeclasses, then the term composed in the sense you are using it: "composed into"; and that same term in the sense the OP used it: "more easily composable units."; are entirely different things.

With the former composing both operations and state, and the latter performing operations on values only (hence stateless). Quite different beasts. The best discussion I have located upon the difference is this.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^4: Roles and functional programming
by dragonchild (Archbishop) on Dec 02, 2008 at 04:29 UTC
    Yeah, that wording is somewhat poor. It really should say something like "Roles can provide attributes." Except, of course, the Role actually has the attribute if you consider the class as a composition of separate roles with the class itself being an anonymous role that is instantiable (which, if you think about it, is one of the two major differences between a class and a role (the other being that a class has to be complete and a role can be incomplete)). And, in any case, the instance of the class is the thing that actually has the attribute, the class merely being the template by which instances are created.

    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-19 17:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found