Disallow null references in safe code?
Xinok
xinok at live.com
Fri Jan 31 17:14:05 PST 2014
I don't know where the community currently stands on non-nullable
types in D, so this idea may be based on a bit of ignorance.
Assuming there are some technical issues preventing non-nullable
types from being implemented, I had a different idea that may be
somewhat of a compromise. As you've gathered by now, it's simply
to disallow nullifying references in safe code.
The idea is simply that safe functions can only call other safe
functions, so null references should be practically non-existant
... except that's an ideal which can't be reached with this
restriction alone. There are two obvious issues:
* There's no way to guarantee input is free of null references
* Trusted functions may return objects with null references; it's
currently not convention to avoid null references in trusted code
Albeit that, I think such a restriction could be helpful in
preventing bugs/crashes and writing correct code, at least until
we can get non-nullable types.
More information about the Digitalmars-d
mailing list