Generic memory allocation in D

Dom DiSc dominikus at scherkl.de
Tue Mar 5 09:33:35 UTC 2024


On Tuesday, 5 March 2024 at 03:26:22 UTC, Walter Bright wrote:
> Don't think I haven't struggled with this question.
>
> Consider also that the convention for system calls is 0 is 
> success and anything else is an error.

I know, and it is odd enough. But here it is boolean. "Anything 
else" is just one value: true. And "true" should never be the 
error value.
Use any other type, and say 1 means "error code 1" instead of 
"true" and then it's ok.
0 is a neutral value, false is not. This is also one major reason 
to not automatically convert from int to bool or vice versa. 
Because then false becomes 0 which changes the meaning heavily.


More information about the Digitalmars-d mailing list