🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sw.components
Article #43

Re: Inheritance vs. component efficienc

#43
From: Jonas Nygren
Date: Sun, 13 Aug 1989 13:32
46 lines
1993 bytes
In article <130200005@p.cs.uiuc.edu> johnson@p.cs.uiuc.edu writes:
>
>Bill Wolfe is right -- I believe the following two things:
<deleted>
>      2) For some reason, run-time binding is necessary.
>
<deleted>
>Consider a windowing system.  A big window can contain smaller windows.
>Each window can display itself.  A large window displays itself by displaying
>its smaller windows.  It would have an array of subwindows, and would
>iterate over them, performing the DISPLAY operation on each one.  However,
>since different subwindows display different kinds of things, there must
>be run-time binding.  In a conventional language this would be implemented
>by case statements.  However, case statements result in code that is much 

If C is to be considered a conventional language then there is a way to avoid
the case-construct. Just declare a structure as follows:

	typedef struct{
		....
		void (*display)();
	} window;

and then the following code would achieve what Ralph wants:

	window a, b;

	....
	a.display = draw_small_window;
	b.display = draw_big_window;
	....
	(*a.display)(a);
	(*b.display)(b);

without case-constructs.

It's even possible to achieve single-inheritance by adding the derived
class's members after the base-class members in a new struct, and this
could be semi-automated by nested include-files.

From my point of view run-time binding is not necessary at all!

>Ralph Johnson


Jonas Nygren
Technical Details
Message-ID: <1233@ttds.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!uunet!mcvax!sunic!kth!draken!ttds!jonasn
References: <5682@hubcap.clemson.edu> <130200005@p.cs.uiuc.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!uunet!mcvax!sunic!kth!draken!ttds!jonasn
From: jonasn@ttds.UUCP (Jonas Nygren)
Newsgroups: comp.sw.components
Subject: Re: Inheritance vs. component efficienc
Summary: run-time binding NOT necessary.
Message-ID: <1233@ttds.UUCP>
Date: 13 Aug 89 13:32:19 GMT
References: <5682@hubcap.clemson.edu> <130200005@p.cs.uiuc.edu>
Reply-To: jonasn@ttds.UUCP (Jonas Nygren)
Organization: The Royal Inst. of Techn., Stockholm
Lines: 46