[Issue 2946] Make 'abstract' mandatory if the class is intended to be abstract

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 21 11:12:55 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=2946


Jacob Carlborg <doob at me.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |doob at me.com


--- Comment #10 from Jacob Carlborg <doob at me.com> 2013-01-21 11:12:53 PST ---
(In reply to comment #0)
> > On Mon, 28 Apr 2008 10:11:23 -0300, Ary Borenszweig
> 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.

There might be a problem with this since D supports separate compilation. There
can be another object file that contains the implementation of
Bar.someAbstract. I'm not sure if this applies here.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list