Rant after trying Rust a bit

jmh530 via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 23 08:20:34 PDT 2015


On Wednesday, 22 July 2015 at 23:25:56 UTC, jmh530 wrote:
>
> If traits were deemed important enough to add to D, I would 
> suggest just extending interfaces so that they have inheritance 
> and can be easily used in template constraints.
>

I think I had a few misconception about D interfaces. The 
documentation does not say anything about interface inheritance, 
but it seems to work when I tried it. It definitely seems weird 
that this behavior isn't mentioned anywhere.

Also, the use of static* or final methods in the interface can 
allow default implementations of methods. This is something that 
can be done with Scala traits. I feel like this isn't 
documentated as well as it could be. A weirder thing is that when 
I tried to test that static and final methods could not 
overridden (which is allowed in Scala), it seemed like they were 
getting overridden. The tricky part is that I had been using 
something like final foo() { } instead of final void foo() { }. 
For some reason you can override the first, but not the second.

So really, I guess the D interfaces are more powerful than I had 
thought. Only downside is that they only work for classes.

* I feel like these also aren't particularly described well in 
the documentation either.


More information about the Digitalmars-d mailing list