三倍速いカウンタ

忘れてた。カウンタを作ったときは継承して3倍速いred_counterも作ることにしているんだった。

# class red_counter=  
    object
      inherit counter as super
      method push = super#push; super#push; super#push; 
    end;;
Warning S: this expression should have type unit.
Warning S: this expression should have type unit.
class red_counter : object val mutable count : int method push : int end
# let rc = new red_counter;;
val rc : red_counter = <obj>
# rc#push;;
- : int = 3
# rc#push;;
- : int = 6

unitでない式をセミコロンでつなぐとwarningがでるのか。

http://itpro.nikkeibp.co.jp/article/COLUMN/20061107/252787/?ST=develop

「inheritance is not subtyping」