[RFC] Throwing an exception with null pointers
Derek Fawcus
dfawcus+dlang at employees.org
Thu Apr 17 10:59:09 UTC 2025
On Thursday, 17 April 2025 at 05:09:41 UTC, Walter Bright wrote:
> ```C
> int foo(int * arg1, int * NULL_UNSPECIFIED arg2, int * NULLABLE
> arg3) {
> ```
>
> https://www.youtube.com/watch?v=vEr0EAcSWcc
Yeah, but that is test code as I'm experimenting with the
mechanism, and trying to figure out how it can be used, and what
(if any) value I perceive it as adding.
I rather suspect the norm would to use the pragma such that most
uses are implicitly non-null, and only the exceptional nullable
pointer would have to be so marked.
On this particular point, my preferred form would be something
similar to what Cyclone had, but not using its syntax forms.
Possibly using the syntax from Zig.
So the common case would be a non-nuull pointer, using '*' alone
in its declaration. The nullable point would probably be
declared as '?*' (or '*?' - not sure which).
Then for use, one could not assign from a nullable to a non-null
unless DFA had already proved the value was not null.
Except those would be non backward compatible changes; so one
would somehow have to opt in to them.
More information about the Digitalmars-d
mailing list