Why is D unpopular?

Siarhei Siamashka siarhei.siamashka at gmail.com
Tue May 24 10:53:19 UTC 2022


On Tuesday, 24 May 2022 at 09:12:02 UTC, forkit wrote:
>> 
>> You just need to remember to use 'enforce' instead of 
>> 'assert'. ....
>
> It's not correct to suggest that these are simply 
> interchangeable.

Of course they are not. Otherwise there would be no need for 
changing 'assert' to 'enforce' in the code in the first place.

> For example (to just make that point):
>
> nothrow void checkSomething(bool checkThis)
> {
>     //enforce(checkThis == true); // nope! enforce throws an 
> exception.
>     assert(checkThis == true); // ok.
> }

Yes, 'enforce' is not usable in some cases, but in many cases it 
is. It can be probably changed to cause abort when used in 
'nothrow' functions instead of failing to compile (yes, I 
understand that this is controversial). Or something with a 
different name can be introduced to cover this case.

Still my point is that having the code that behaves correctly 
only when used together with some special command line option is 
not a great idea. You never know who is going to compile your 
code and what kind of options they are going to use to hurt 
themselves. And when they do, it's you who has to provide support 
and do the necessary detective work to even figure out what 
exactly happened.


More information about the Digitalmars-d mailing list