What are the prominent downsides of the D programming language?

Paulo Pinto pjmlp at progtools.org
Wed Sep 30 13:37:02 UTC 2020


On Wednesday, 30 September 2020 at 12:34:48 UTC, Adam D. Ruppe 
wrote:
> On Wednesday, 30 September 2020 at 02:17:37 UTC, H. S. Teoh 
> wrote:
>> How is multiple interface broken?
>
> interface A { void foo(); }
> interface B { void foo(); }
>
> class C : A, B { void foo() {} }
>
> If there's two interfaces with the same method signature, D 
> merges them by the time you get to the implementation class.
>
> You could argue this is irrelevant and not actually broken but 
> like... idk I see the point.
>
>> Java has multiple interfaces. Are you saying that Java is 
>> broken?
>
> Yes, Java does it this way too.
>
> C# doesn't though: there you can specify which interface you 
> want to implement.

interface Gun { void fire(); }
interface Rocket { void fire(); }

class Weapon : Gun, Rocket { void fire() {} }

void protectMyself(Gun g) {
   g.fire(); // what did I actually do here?
}

void defence(Weapon w) {
   protectMyself(w);
}

The name might be merged, but semantics aren't the same and 
sometimes the unexpected happens, that is why Eiffel and .NET 
languages approach to explicitly state the interface 
implementations are much better.


More information about the Digitalmars-d mailing list