Did You Really Understand Super?

Damien Cassou, St├ęphane Ducasse and Luc Fabresse http://stephane.ducasse.free.fr

What You Will Learn

Revisit

A Little Puzzle

Dice class >> new

  | inst |
  inst := super new. 
  inst initialize.
  ^ inst

We execute the following expression: Dice new

Questions

Dice class >> new

  | inst |
  inst := super new. 
  inst initialize.
  ^ inst

Hint: super is Not...

Dice class >> new

  | inst |
  inst := super new. 
  inst initialize.
  ^ inst

Hint 2: super is the Message Receiver

Dice class >> new

  | inst |
  inst := super new. 
  inst initialize.
  ^ inst

Sending a Message: Lookup + Apply on Receiver

Remember: Method Lookup

Solution

Dice class >> new

  | inst |
  inst := super new. 
  inst initialize.
  ^ inst

Solution

Summary

Challenge?

Challenge!

Imagine we have

A >> foo
   ^ super class == self class 

What is the result of A new foo and why?

/