'idiomatic' porting of c and or c++ code that does NULL checking

nikki via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Aug 23 03:33:00 PDT 2014


On Saturday, 23 August 2014 at 10:29:04 UTC, ketmar via 
Digitalmars-d-learn wrote:
> On Sat, 23 Aug 2014 10:19:58 +0000
> nikki via Digitalmars-d-learn 
> <digitalmars-d-learn at puremagic.com> wrote:
>
> don't use '==' to check for nulls. the right way is:
>
>   if (foo is null) {}
>   if (bar !is null) {}
>
> '==' transforms to opEquals call (see 'operator overloading') 
> and 'is'
> not.
>
> as for 'best practice' question -- it depends of many things. 
> ;-)

A good to know! thanks.
I'd still be interrested to see the idiomatic D version of that 
function, what would that depend on ?


More information about the Digitalmars-d-learn mailing list