閑古鳥

オールドプログラマの日記。プログラミングとか病気(透析)の話とか。

this が参照ではなくポインタである理由

単純に参照ができる前に this ポインタができたからだそうで。

Why is "this" not a reference?
Because "this" was introduced into C++ (really into C with Classes) before references were added. Also, I chose "this" to follow Simula usage, rather than the (later) Smalltalk use of "self".

this ポインタは NULL になる可能性もあるから、敢えて建前では NULL になりえない参照ではなくポインタにしたのかなと思ったんですが。まあ、 this が NULL の時に動く非 sitatic メンバ関数ってどうよとも思うので、参照の方が理に適っていると言えなくもない、かも。