Why is D unpopular?
Paul Backus
snarwin at gmail.com
Mon May 23 01:37:09 UTC 2022
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.
More information about the Digitalmars-d
mailing list