A Modest Proposal: Final class instances

div0 div0 at users.sourceforge.net
Tue May 5 13:08:20 PDT 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Walter Bright wrote:
> dsimcha wrote:
>> == Quote from Walter Bright (newshound1 at digitalmars.com)'s article
>>> dsimcha wrote:
>>>> A possible
>>>> solution is, given a class:
>>>>
>>>> class Foo {
>>>>     // Actual implementation.
>>>> }
>>>>
>>>> final class FooFinal : Foo{
>>>>     // Dummy that just makes Foo final.
>>>> }
>>> With dmd:
>>>    final class A { }
>>>    class B : A { }
>>> Compiling:
>>>    test.d(2): Error: class test.B cannot inherit from final class A
>>
>> Uh...I think you misread this.  I was inheriting from a non-final
>> class to make it
>> final, not the other way around.
> 
> 
> Since all classes inherit from Object, this does indeed do what you
> asked for.
> 
> Try it. You'll find it "finalizes" the class. I'd also suggest trying
> out some calls to virtual functions in a final class, and running the
> result through obj2asm to see what happens.

Hey thats great.

Now all we need is the 'virtual' keyword to go with some the methods of
the final class... :O
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFKAJy0T9LetA9XoXwRAl0sAJ41lAoVEz9iYJZvfr2Cn9yl7ZNBwgCgxXGB
MI+3ICSwL7OGMRx0Nd2c+2c=
=uClG
-----END PGP SIGNATURE-----



More information about the Digitalmars-d mailing list