Hi all.
Sorry if this idea|question has been discussed or has name which i don't know about.
<snip>
I'd like to write
Class myclass : a { forget method area; forget method move; method put; }
so methods getX, getY, size will be 'inherited'. Methods 'area' and 'move' will be not present in myclass at all! so $a = new myclass; $a.area()
will return an error. At some level of inheritance methods area() and move() may be reimplemented again if required.
At first, I thought "Hmmm, I'm not sure if this will be useful. Besides, what would happen in the case of multipile inheri..." Then, it hit me. A "forget" (or "block", or something similar) keyword would be great in clearing up confusion with multiple inheritance.
For instance, in an example like:
class A {
method a_method {}
method common_method {}
}
class B {
method b_method {}
method common_method {}
}
class C is A,B { # Is that right, or am I too java-ed out?
method c_method {}
forget A::common_method; # or maybe something like: "block A::common_method" }
Class C would now have access to: A::a_method, B::b_method, C::c_method, and B::common_method
Of course, roles are another great way to prevent confusion with multiple inheritance. A good question would be whether something like "forget" is useful in addition, or whether everyone should just use roles. :)
- Joe