On 3 févr. 2014, at 17:37, Clément Bera <bera.clement@gmail.com> wrote:
Right, that's why there's #perform:withArguments:inSuperclass: . Amazingly, #perform:withArguments:inSuperclass: works only if the superclass is in the lookup chain but does not necessarily requires the direct superclass.
It's because you don't know in which class the method that use super is. The lookup must start in the correct class (the superclass of the class of the method that use super) that is not necessarily the direct superclass of the object.
Let's say A inherits from B inherits from C.
A>>foo ^ #c B>>foo ^ #b C>>foo ^ #c A>>superSend ^ super foo
A new foo "answers a" A new superSend "answers b"
And you cannot directly reach c, however:
A new perform: #foo withArguments: #( ) inSuperclass: A "answers a" A new perform: #foo withArguments: #( ) inSuperclass: B "answers b" A new perform: #foo withArguments: #( ) inSuperclass: C "answers c" A new perform: #foo withArguments: #( ) inSuperclass: Object "DNU" A new perform: #foo withArguments: #( ) inSuperclass: UndefinedObject "class not in my lookup chain"
Ah the dark side of the force. Always tempting but so dangerous in the long term.
2014-02-03 Benjamin <benjamin.vanryseghem.pharo@gmail.com>: On 03 Feb 2014, at 16:26, Norbert Hartl <norbert@hartl.name> wrote:
I just wanna share my newest finding in producing endless loops.
foo super perform: #foo
Somehow I like it! :)
Should confuse a lot of JAVA-ist :P
Ben