On 2014-01-17 17:52:18 +0000, "Yota" <[email protected]> said:
On Friday, 17 January 2014 at 15:05:10 UTC, Michel Fortin wrote:
Couldn't we just add a class declaration attribute that'd say that by
default this type is not-null?
I have been hoping D would become not-null-by-default since I
discovered the language. Looking at what it has done with other type
classes, (shared, immutable, etc) it always seemed like something that
would be right up its alley. However in my dream world, it would
simply apply to all reference types by default.
Well, nothing prevents that from happening if @notnull is adopted. As
proposed, @notnull is designed to keep the language backward
compatible: it's opt-in and you don't even have to opt-in all at once.
Potential problems the early implementation might have can only burn
those who give it a try.
One can hope the feature will become so loved that it'll become
standard pointer behaviour one day, but that can't happen as long as
the feature is theoretical. In the eventuality we decide one day to
push not-null behaviour to the rest of the language, @notnull will just
become an attribute with no effect.
--
Michel Fortin
[email protected]
http://michelf.ca