Negation of attributes (DIP 79)

Liam McSherry via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 2 04:07:19 PDT 2015


In the examples you give, you could surround the final methods in 
a final block. Testing with dmd 2.067.1, the following works:

---
class C
{
     final
     {
         void nonOverrideable()
         {
             "Hello, World!".writeln;
         }
     }

     bool overrideable()
     {
         return true;
     }
}

class D : C
{
     override void nonOverrideable() // Error
     {
         "Goodbye!".writeln;
     }

     override bool overrideable() // No error
     {
         return false;
     }
}
---

To me, at least, it's also more intuitive than "!final:".


More information about the Digitalmars-d mailing list