Null references redux

bearophile bearophileHUGS at lycos.com
Sun Sep 27 14:17:46 PDT 2009


Jarrett Billingsley:

> And if you have a nullable reference that you know is not null for the
> rest of the function? Just put "assert(x !is null)" and everything
> that follows will assume it's not null.

Asserts tend to vanish in release mode, so it may be better to use something different. A possibility is to use the enforce() some people have shown here.

Another possibility is the very strange assume() of Visual C++, that I may appreciate for other purposes too:
http://msdn.microsoft.com/en-us/library/1b3fsfxw(loband).aspx

Bye,
bearophile



More information about the Digitalmars-d mailing list