Why is D unpopular, redux.

rikki cattermole rikki at cattermole.co.nz
Fri May 20 12:59:04 UTC 2022


On 20/05/2022 11:28 PM, deadalnix wrote:
> Apparently, we are getting named argument soon. I have no opinion 
> whether this is good or bad, I haven't even read he proposal. But I 
> don't need to to know this is pretty bad for D, even if the proposal is 
> really good.

As a previous author of a named parameter DIP, I can say its a good DIP 
but it doesn't solve a pretty important thing. The ability to access 
template parameters as if they were a member externally.

As Max discovered, its a lot of work to implement. So much technical 
debt and so little refactoring going on. Oh well.

 > I'd like to remind everybody of a simple fact: it is impossible to 
write a high quality generic container in D, right now. This is because 
there is no way to explain to the compiler that a `const Vector!T` is 
the same as a `const Vector!(const T)`.

The things that concern me wrt. data structures are:

I can't ``@disable const;`` and stop the outer type being able to become 
const. It is a lot of work to prevent it.

Why can't I support const? To iterate, you need to be able to mutate 
state. This includes an iterator (for concurrent iteration + mutation 
support). And of course reference counting.

For data structures, because they must be able to mutate state, const is 
effectively immutable. You can't know if the state is in read only 
memory or not. So the only thing you can do is throw up your hands and 
go, nope not my problem!

This of course becomes a pain if you need to return say a list of 
strings that was computed at the start of a program that will never 
change. But once you return it, anyone can change it. I'm now 
considering copy on write for them wholesale.

All this before we consider lifetime issues *sigh*.


More information about the Digitalmars-d mailing list