null in D

bearophile bearophileHUGS at lycos.com
Tue Aug 19 08:37:23 PDT 2008


Steven Schveighoffer:
> I would expect this probably is a side effect of 1) that NULL is not part of 
> the language, and 2) some C standard libraries define NULL as 0.  Some 
> define NULL as (void*)0, which probably don't have this problem.

Well, what you say here is generally not precise/almost wrong regarding C; that FAQ explains how things are.
And NULL defined as (void*)0 can't solve that problem, it seems.
I did suppose to know enough C before reading that FAQ ;-)


> I expect in D that since null is a first-class keyword, and not some alias 
> or definition, its usage is understood correctly by the compiler to always 
> be a pointer or null reference.

I expect it too, but I'd like to be sure :-)


> That being said, overloaded functions which have 2 versions which take 
> different reference types must be selected by using a cast.

I agree.

Bye and thank you,
bearophile


More information about the Digitalmars-d-learn mailing list