Fixing C's Biggest Mistake

Dukc ajieskola at gmail.com
Sat Jan 14 12:15:46 UTC 2023


On Saturday, 14 January 2023 at 10:59:38 UTC, Max Samukha wrote:
> My point is you can rarely decide upfront how to handle input 
> to a public API, because the decision depends on how the API 
> will be used:
>
> (1)
> ```
> to!int(readln); // "bad input error", expected to be recoverable
> ```
>
> (2)
> ```
> string s = <computation that may contain a logic error>
> to!int(s); // "logic error", expected to panic
> ```
>
> If you decide on 'assert', then (1) will require a redundant 
> 'enforce'. If you decide on 'enforce', then (2) will require a 
> redundant 'assert'.

The distinction between recoverable and unrecoverable errors is 
still relevant. The library author is only picking the default. 
User still needs to make the decision.


More information about the Digitalmars-d mailing list