does D already have too many language features ?

Dennis dkorpel at gmail.com
Mon Apr 8 22:06:33 UTC 2019


On Monday, 8 April 2019 at 20:38:57 UTC, Mike Franklin wrote:
> Mix in D's design by introspection(DbI) features, `alias this`, 
> `mixin`s, etc. and we're 70% there. Due to DbI, interfaces 
> could probably go away today.

I don't buy the notion that D classes are ready to be deprecated, 
even ignoring code breakage and familiarity for C++ / C# / Java 
programmers. Alias this and mixin simply still feel too immature 
to me; whenever I'm casually trying to get some subtyping done 
and I always get stopped by bugs or design limitations (examples 
[1][2][3]).

Looking at this page:
https://tour.dlang.org/tour/en/gems/subtyping
I always associated alias this with subtyping, and any violations 
of the Liskov substitution principle were bugs / design aspects 
to be ironed out.
However, from the generality creep thread [4] it became clear 
that "alias this to an rvalue is not subtyping". "Odd" was 
Andrei's reaction. It's really hard to sell "classes are totally 
not needed in D, just use alias this for subtyping" when it's so 
complicated to reason about and it fails so often.

I didn't expect myself to defend classes here since I avoid them 
if I can (mostly for memory efficiency), but I have to say their 
design and implementation are much more robust than template 
meta-programming currently. I like that D offers subtyping 
without everything being an Object, but I tend to see templates 
as a more low-level, somewhat experimental way that accompanies 
classes, not a replacement of classes.

[1] 
https://forum.dlang.org/thread/ibordxozjckquanrskap@forum.dlang.org
[2] https://issues.dlang.org/show_bug.cgi?id=19365
[3] https://issues.dlang.org/show_bug.cgi?id=19476

[4] https://forum.dlang.org/post/q6plhj$1l9$1@digitalmars.com


More information about the Digitalmars-d mailing list