[D typesystem] What is the type of null?
dsimcha
dsimcha at yahoo.com
Tue Oct 12 07:58:02 PDT 2010
== Quote from Justin Johansson (no at spam.com)'s article
> Given that if a function should return something,
> and that function may return null in, at least
> reference type return scenarios, one would expect that
> "null" has a type.
> What is the type of "null" in the D typesystem?
> - JJ
I see it as a polysemous value, kind of like 1. typeof(1) is int. auto foo = 1;
makes foo an int. However, the literal 1 can be assigned to any integral type,
even ones that an int can't be.
Similarly, null can be assigned to class references and pointers to any type, even
though a void* can't be.
More information about the Digitalmars-d
mailing list