RFC: Change what assert does on error
Sebastiaan Koppe
mail at skoppe.eu
Fri Jul 4 12:41:38 UTC 2025
On Sunday, 29 June 2025 at 18:04:51 UTC, Richard (Rikki) Andrew
Cattermole wrote:
> Hello!
>
> [...]
>
> Destroy!
Somewhat unrelated to this discussion, but I have come of the
opinion that a large portion of asserts are actually people
'protecting' their libraries, which, if they designed them right,
wouldn't need an assert in the first place.
You can typically tell where they are when you see documentation
like "it is forbidden to call this method before X or after Y".
Often these things can be addressed by encoding the constraints
in the types instead, and in the process eliminating any need for
an assert at all.
It would be interesting to see how many actual uses of assert in
common D libraries are actually the consequence of such design
decisions.
More information about the Digitalmars-d
mailing list