Should certain abstract classes be instantiable?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Oct 1 20:48:47 PDT 2009


Jarrett Billingsley wrote:
> On Thu, Oct 1, 2009 at 8:49 PM, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
>> Jarrett Billingsley wrote:
>>> On Thu, Oct 1, 2009 at 4:30 PM, Andrei Alexandrescu
>>> <SeeWebsiteForEmail at erdani.org> wrote:
>>>> Consider:
>>>>
>>>> class A {
>>>>   abstract void fun() {}
>>>> }
>>>>
>>>> The class defines a function that is at the same time abstract (so it
>>>> requires overriding in derivees) and has implementation.
>>>>
>>>> Currently the compiler disallows creation of objects of type A, although
>>>> technically that is feasible given that A defines the abstract method.
>>>>
>>>> Should A be instantiable? What designs would that help or hinder?
>>> Uh... why?
>> Because I want to give a good argument one way or another in TDPL. FWIW, "I
>> can't imagine why you'd ever..." or "Never needed that" are not strong
>> enough arguments.
> 
> But.. you mark something abstract when you want it to be .. abstract.
> How would you argue that abstract is basically a no-op when used on
> methods with bodies?

It's not a no-op. Try it.

Andrei



More information about the Digitalmars-d mailing list