🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.java
Article #23

Re: Are "super" and "this" different objects?

#23
From: Piercarlo Grandi
Date: Sun, 29 Oct 1995 18:21
48 lines
2618 bytes
>>> On 27 Oct 1995 16:09:27 -0600, Vladimir Alexiev
>>> <vladimir@cs.ualberta.ca> said:

Vladimir> In article <vwjbur5e1td.fsf@osfb.aber.ac.uk> pcg@aber.ac.uk
Vladimir> (Piercarlo Grandi) writes:

pcg> In other words, in Smalltalk 'self == super' is true by definition, and
pcg> it is only method lookup that differs.
pcg> [In this respect C++ is] Exactly like in Smalltalk...

Well, I really meant [In this respect Java is], sorry it was not clear.
Java has super, with typeof(super) == typeof(ancestorof(typeof(this))),

Vladimir> Actually since C++ has multiple inheritance, it can be
Vladimir> different. Now, C++ does not have "super" to begin with, so we
Vladimir> have to be a bit flexible in our comparison. Consider
Vladimir>   class A : B, C
Vladimir> Then if a is a pointer of type A, (void*)a==(void*)(B*)a,
Vladimir> however (void*)a!=(void*)(C*)a, because the subobject C does
Vladimir> not start at the same offset as A (while B does).

This is a bit offtopic (the discussion was about Java, which is merely
similar to C++), but I agree wholeheartedly, in particular because it is
a good ilustration of my long usual refrain that the notion of
inheritance as prefixing, inherited :-) all the way from Simula 67, is a
bad idea.

With a minuscule little rule taken from PL/1 and Cobol (that any member
of a structure can be named with any unique subset of its full dotted
name) inheritance can simply disappear, folded back into composition,
with no loss, and lots of gain (in other words, delegation rules the
classes! :->).

  Example:

	struct A { ... a ... f() }
	struct B { ... b ... g() }
	struct C { ... A x ... B y ... c ... g() ... }

	struct C z;
	assert (&z.a == &z.A.a);
	assert (&z.g == &z.B.g);

Another little useful addition would be member pointers done right,
i.e. relative pointers, to allow both self-relocating data and going
from the part to the whole without using the structof macro.

Well, dream on.
Technical Details
Message-ID: <vwjbur0w3qe.fsf@osfb.aber.ac.uk>
Path: arc1-ca.pugleaf.net!bath.ac.uk!aber!innews
References: <1995Oct23.154442.6836@schbbs.mot.com> <omloq6h948.fsf@tees.cs.ualberta.ca>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!bath.ac.uk!aber!innews
From: pcg@aber.ac.uk (Piercarlo Grandi)
Newsgroups: comp.lang.java,comp.object,comp.lang.c++
Subject: Re: Are "super" and "this" different objects?
Date: 29 Oct 1995 18:21:13 +0000
Organization: Prifysgol Cymru, Aberystwyth
Sender: pcg@osfb.aber.ac.uk
Message-ID: <vwjbur0w3qe.fsf@osfb.aber.ac.uk>
References: <1995Oct23.154442.6836@schbbs.mot.com>
 <omloq6h948.fsf@tees.cs.ualberta.ca>
Reply-To: pcg@aber.ac.uk (Piercarlo Grandi)
NNTP-Posting-Host: osfb.aber.ac.uk
In-reply-to: Vladimir Alexiev's message of 27 Oct 1995 16:09:27 -0600
Precedence: first-class
X-Newsreader: Gnus v5.0.4