dereferencing null

Adam D. Ruppe destructionator at gmail.com
Mon Mar 5 16:36:12 PST 2012


On Tuesday, 6 March 2012 at 00:01:20 UTC, Jason House wrote:
> The opAssign kills all type safety. I think only NotNull!T 
> should be accepted... So "foo = bar" won't compile if bar is 
> nullable. To fix, "foo = NotNull(bar)",

In both cases, the assert(x !is null), whether in
opAssign or in the constructor, is going to fire,
preventing the assignment.

Losing the opAssign would force you to think about
it, but I was concerned that it'd make it annoying
to use in a case where you already know it is not
null.

Perhaps worth it? I'm undecided. The constructor is
the important part, definitely.


More information about the Digitalmars-d mailing list