[Survey] About the cognitive surcharge of super

Andreas Raab Andreas.Raab at gmx.de
Fri Sep 6 18:20:01 UTC 2002


Stephane,

> MyClass>>test1
> 	^ super == self
> 
> MyClass>>test2
> 	^ self class == super class
> 
> 
> then asked MyClass new test1 and MyClass new test2.

It must be true and true but it took me a while to get down to *why*
this is. BTW, the test is not very good here since actually #class is a
special selector (represented as bytecode) which is never looked up. But
the principle is right.

> Do the test before reading further...
> 
> I found that lot of people were confused by the second test.

Probably so. Part of it is that it's easy to confuse "super class" with
"superclass" which have wildly different meanings. 

The other issue is that because of the minimal syntax employed in
Smalltalk it's easy to think about "super" as a variable with the
meaning of "the receiver cast to its superclass" (to borrow a horrible
meaning from some well-known other languages ;-) It would probably be
more explicit to use #perform:inSuperclass: instead.

Cheers,
  - Andreas




More information about the Squeak-dev mailing list