Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!cs.utexas.edu!news.ti.com!ticipa!clw
From: clw@ticipa.pac.sc.ti.com (Chris Winemiller)
Subject: Re: How does the instance's class get set?
Message-ID: <1995Jan16.145425.1747@ticipa.pac.sc.ti.com>
Organization: None
References: <guzdial-1401951132340001@guzdial.cc.gatech.edu> <1995Jan14.191650.1285@ticipa.pac.sc.ti.com> <3fctka$mdk@isnews.is.s.u-tokyo.ac.jp>
Date: Mon, 16 Jan 1995 14:54:25 GMT
Lines: 48

In article <3fctka$mdk@isnews.is.s.u-tokyo.ac.jp> jeff@is.s.u-tokyo.ac.jp writes:
>In article <1995Jan14.191650.1285@ticipa.pac.sc.ti.com> clw@ticipa.pac.sc.ti.com (Chris Winemiller) writes:
>
> |The special variable "self" always refers to the receiver of a message,
> |but "super" *also* refers to the receiver of a message. "super" and "self"
> |refer to the same object, but they differ in where the message lookup
> |begins for messages sent to them. For self, the message lookup begins in
> |the class of self. For super, the message lookup begins in the
> |_superclass_ of self.
>
>A subtle but important error here.  super does not refer to the
>superclass of the receiver's class but to the superclass of the class
>in which the current method is installed (see the CompiledMethod's
>methodClass instVar).  This is VERY important.  Without this property,
>chained super sends would not work.  That is, if Ball>>new did "super
>new" and super is defined as the superclass of the receiver's class
>then that would be Ball again!

How about a compromise? :-)  Thanks for catching a subtle error in my
post, but I think there's still a problem with your own. :-) How's this
for a correct interpretation:

The special variable "self" always refers to the receiver of a message. 
The special variable "super" *also* refers to the receiver of a message.
"super" and "self" refer to the same object, but they differ in where
the message lookup begins. For self, the message lookup begins in the
class of self. For super, the message lookup begins in the superclass of
the class in which the current method is installed (i.e, in the
superclass of the class which implements the method now being executed).

In other words, I agree with you about where the message lookup begins
for super; but I think I'm correct in saying that super and self refer to
one and the same object.  super does not refer to the superclass of the
receiver's class; it refers to the receiver itself, just like self. 
Otherwise, in the example:

    Apple class>>new
        ^super new initialize

this would return an instance of some superclass rather than an instance
of Apple.

Regards,
Chris
==============================================================
Chris Winemiller               Internet: clw@works.ti.com
Disclaimer: I do not speak for TI.
==============================================================
