Why is D unpopular?

claptrap clap at trap.com
Mon May 23 09:45:21 UTC 2022


On Monday, 23 May 2022 at 01:37:09 UTC, Paul Backus wrote:
> On Sunday, 22 May 2022 at 11:49:27 UTC, forkit wrote:
>> On Friday, 20 May 2022 at 06:40:30 UTC, Tejas wrote:
>>>
>>>
>>> Isn't the advice to use `enforce` for handling/verifying 
>>> input in release builds and `assert` for development builds 
>>> though?
>>> Yeah, it's violating DRY if a particular check needs to be 
>>> done in both development and release, but then one can skip 
>>> the `assert` and just do `enforce`, no?
>>
>> argh!
>>
>> I often forget that D removes assert in release mode :-(
>>
>> If only we had Rust style asserts.
>>
>> And by that, I specifically mean:
>>
>> "Assertions are always checked in both debug and release 
>> builds, and cannot be disabled. See debug_assert! for 
>> assertions that are not enabled in release builds by default."
>>
>> https://doc.rust-lang.org/std/macro.assert.html
>
> We actually have this in D, it's just written weirdly:
>
> ```d
> // debug assertion
> assert(condition);
>
> // release assertion
> if (!condition) assert(0);
> ```
>
> It would probably be more intuitive if we could write release 
> assertions as plain `assert`, and use `debug assert` for debug 
> assertions. But the functionality is there.

Thats a prime example of one of the main things that irritate me 
about D. For the sake of not adding a new keyword or something 
like that, instead a special case is added. Asserts are removed 
in release mode unless it is assert(0). Its idiotic.

assert(0) isn't even an assert, it's abort().

uuugh.

Sometimes it feels like D is intent on finding the most ways to 
reuse the same keyword to mean different things in different 
contexts.




More information about the Digitalmars-d mailing list