Walter's second axiom

Stewart Gordon smjg_1998 at yahoo.com
Sat Dec 8 05:31:52 PST 2007


"Janice Caron" <caron800 at googlemail.com> wrote in message 
news:mailman.270.1197118522.2338.digitalmars-d at puremagic.com...
<snip>
>    struct S : T {}
>
> to create a struct S which behaves exactly like a T. For example
>
>    struct MyInt : int
>    {
>        /* extra functions */
>    }
<snip>

S or MyInt should be a union rather than a struct.  This is because it 
doesn't make sense to add more member variables to the derived type (it 
would increase the size, thereby violating the 'is a' principle of 
inheritance).  However, it does make sense to add more views of the data, 
which is a common use of unions.

I briefly mentioned it here:
http://www.digitalmars.com/d/archives/digitalmars/D/42035.html#N42048

Stewart.

-- 
My e-mail address is valid but not my primary mailbox.  Please keep replies 
on the 'group where everybody may benefit. 




More information about the Digitalmars-d mailing list