Make 'abstract' mandatory if the class is intended to be abstract, absence of 'abstract' means "not abstract"

Christopher Wright dhasenan at gmail.com
Mon Apr 28 18:31:08 PDT 2008


Ary Borenszweig wrote:
> A class can either be abstract or not abstract. Currently in D, if you 
> don't mark a class as abstract, it can still be it if it contains an 
> abstract method:
> 
> class Foo {
>     
>     abstract void someAbstract();
>     
>     void nonAbstract() {
>     }
>     
> }
> 
> When designing a class, you have in mind whether the class is going to 
> be abstract or not. If it's not going to be abstract, you want the 
> compiler to help you by telling you "You made a mistake. This class is 
> still abstract because you didn't implement method foo".
> 
> So I want to extend Foo with a class Bar, but I want Bar to be not 
> abstract.
> 
> class Bar : Foo {
> }
> 
> I compile, and it gives no error, of course. But I want there to be an 
> error there.

You have my support. With the new hiding as an error thing, my faith in 
Walter thinking of catching stupid errors is shored up, and I have a 
reasonable hope that this suggestion will succeed.



More information about the Digitalmars-d mailing list