From -3074660796193699628
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,82b9a0e2d78eb842
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1995-03-08 02:06:37 PST
Newsgroups: comp.std.c++
Path: bga.com!news.sprintlink.net!howland.reston.ans.net!news.moneng.mei.com!uwm.edu!news.alpha.net!news.mathworks.com!newshost.marcam.com!uunet!in1.uu.net!mole-end!mat
From: mat@mole-end.matawan.nj.us
Subject: Re: Sealed Classes
Message-ID: <1995Mar8.071916.2704@mole-end.matawan.nj.us>
Organization: :
References: <3jfilh$m8s@panix3.panix.com>
Date: Wed, 8 Mar 1995 07:19:16 GMT
Lines: 40

In article <3jfilh$m8s@panix3.panix.com>, tmurphy@panix.com (Timothy Murphy) writes:
> Sealed classes.
> 
>    A sealed class (terminology borrowed from Dylan) is one that prohibits
> derivation.  Andrew Koenig gives a clever method of achieving this in C++
> (see B. Stroustrup "The Design and Evolution of C++", section 11.4.3).
> Here is a variant that I occasionally use:
> 
> 
> /* Prohibit class derivation; to prevent derivation from a class foo,
>    simply inherit privately and virtually from seal<foo>:
> 
> 	class foo :  ... private virtual seal<foo> ... { ... };
> 
>    Relies on fact that virtual bases must be initialized by leaves.
>    Costs a word of storage in the sealed class. */
> 
> template<class T>
> class seal {
> 	typedef T thing;	// friend T; and friend class T; don't work (why?)
> 	friend thing;
> 	seal() {};			// only T can access private ctor.
> };
> 
>    I propose that the idea of a sealed class be elevated to a language
> construct, largely for efficiency purposes.  If the compiler knows that
> a class is sealed, it may optimize away virtual function dispatch
> through pointers/references to that class.  ...

Not important enough to add to C++ at this time.

Besides, this is the wrong place, and you are using the wrong way, to
propose a language extension.

And you are about 24 months too late.
-- 
 (This man's opinions are his own.)
 From mole-end				Mark Terribile
 mat@mole-end.matawan.nj.us, Somewhere in Matawan, NJ
	(Training and consulting in C, C++, UNIX, etc.)


