Why is D unpopular?
Loara
loara at noreply.com
Tue May 24 12:51:14 UTC 2022
On Monday, 23 May 2022 at 01:37:09 UTC, Paul Backus wrote:
> 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.
I think this is better
```d
// debug assertion
assert(condition);
// release assertion
if (!condition) throw new AssertError();
```
or also
```d
// debug assertion
assert(condition);
// release assertion
if (!condition) throw new MyCustomError("My error message");
```
so when your program fails the final user is aware of what went
wrong.
More information about the Digitalmars-d
mailing list