Opt-in non-null class references?
SimonN
eiderdaus at gmail.com
Wed Feb 28 15:56:47 UTC 2018
On Wednesday, 28 February 2018 at 15:29:17 UTC, Mike Franklin
wrote:
> You might be interested in this little experiment:
> https://github.com/dlang/dmd/pull/7375
Indeed, this looks extremely useful, at the very least in a
linter. I probably rely on ints getting initialized to 0
throughout the program, and only rarely make that explicit.
With null references, the problem is not forgetting the
initialization; it's expressing the intent of the variable.
Usually, I want the non-null, but sometimes, I want a nullable
reference and would like to require the using code to test the
reference for null. Merely verifying for initialization doesn't
help here; it may well be intended that null will be assigned
later to the reference.
-- Simon
More information about the Digitalmars-d
mailing list