-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Roles Feedback #9
Comments
I don't find arguments about silently changing behavior due to classes overriding role methods particularly convincing. Inheritance has the exact same issue. Roles probably need to be able to provide behavior like the
This is not obvious to do. Also this requires method modifiers, which are excluded from this proposal for roles. Having them be separate keywords or something similar may make sense. But allowing roles to have behavior tied to construction or destruction prevents them from being commutative. This includes attributes with immediate defaults. But I don't think preventing roles from having any construction time behavior is viable. Excluding method modifiers to preserve commutative properties that are already not guaranteed is a mistake, I believe. |
I have questions about the behavior:
Consider the example from the classes page:
Serialization makes sense for a role. But how to implement this role? Somehow the role needs to collect the relevant data from the object. With Moo*, well, we know it's just a hash reference, so just dump that and on de-serialization load that dump and bless it into the object's class. Pretty generic, reusable stuff. Breaking encapsulation? Who cares, it works. With Cor such hackery is gone. With a required method a role could force the class to provide its content in a serializable fashion, it could be a private method to avoid a bloated interface. Also, de-serialization raises questions, but that's outside the scope of the "Roles" topic. |
@HaraldJoerg A roles does not have access to the slots or other innards of the consuming class. Instead, if that class provides public methods (even via Yes, private methods should be sufficient for the |
I miss a 'does' (or similar) method to check on an object if a particular behavior/interface is supported. One could use 'can' instead and check for a particular method name, but this is prone to accidental name conflicts. Not sure if this belongs into the role rfc, though. |
@haarg wrote:
Given that roles were invented and later formalized to fix the problems with inheritance, I think that should answer the question. Heck, this is enough of an issue with inheritance that Java introduced the In traits, the researchers modified the Smalltalk browser to signal to developers that a method was "shadowing" a role method. It was never intended to be silent action at a distance. Wondering why role isn't functioning the way I expect because I've silently replaced the
I believe we've gotten to the point where I reluctantly agree with this, but we've punted on this behavior for V1. Given that the majority of OO languages out there seem to be able to do without method modifiers suggests to me that we should at least see what comes out of this for Corinna. Your other points about |
@HaraldJoerg asked:
No.
Not at this time, because a role cannot see private methods in other namespaces. At some point we'll need to address this. Java has a similar issue with interfaces in that they can't do much with protected methods, so everything via interfaces is public. This, I think, is a mistake. However, I want to tread lightly here because it seems like this is easy to get wrong. Thus, is seems more of a V2 feature. |
With reluctance, closing this because it doesn't seem to impact the accepted MVP. |
Use this issue to provide feedback on the Roles Proposal.
The text was updated successfully, but these errors were encountered: