Does D have too many features?

H. S. Teoh hsteoh at quickfur.ath.cx
Sat Apr 28 14:59:50 PDT 2012


On Sat, Apr 28, 2012 at 11:42:31PM +0200, Peter Alexander wrote:
[...]
> - UFCS. It's just sugar, but adds complexity.

On the contrary, it's a major helper for writing generic code. In my new
AA implementation, I use UFCS to provide a default toHash function for
all types that don't already provide one. Without UFCS, this would
require lots of ugly hacks and constraints on how user code can provide
custom hash functions. (Due to the way D overloading works, UFCS is
currently the only way to provide a default function without causing a
conflict at compile-time.)


> - const/immutable/inout/shared/pure. These add massive complexity to
> the language for little (IMO) benefit. When I do multi-threading, I
> usually have to resort to casting. Maybe these will improve with
> time.

Yeah they are complex, but they also open ways for powerful
optimizations by the compiler.

Though I do have to say that inout needs some serious reconsideration,
since the way they work currently is ambiguous when you have more than
one inout argument, or when you have a delegate parameter with inout
arguments.


> - opDispatch. I think it just promotes sloppy, obfuscated code for
> minor syntactical benefit.

Wrong. It's a powerful tool for building runtime dynamic class loading.
It allows you to write generic code that Just Works without having to
special-case them for statically-known classes vs. dynamic classes. If
anything, I'd argue for *more* similar features that let you write
generic code that integrates seamlessly into the language.

Just because it's been used (arguably abused) for things like making
roman numerals or vector swizzling, doesn't mean it's a bad feature.


> Member access through pointers should require -> like in C++ so that
> you can overload it for smart pointer/reference ADTs.
[...]

Yikes!! Please don't reintroduce that monstrous -> operator from C++!
(Besides, most of the time idiomatic D code doesn't even need pointers.)


T

-- 
If you look at a thing nine hundred and ninety-nine times, you are perfectly safe; if you look at it the thousandth time, you are in frightful danger of seeing it for the first time. -- G. K. Chesterton


More information about the Digitalmars-d mailing list