[D typesystem] What is the type of null?

Stanislav Blinov blinov at loniir.ru
Tue Oct 12 08:17:09 PDT 2010


  12.10.2010 18:43, Justin Johansson пишет:
> On 13/10/2010 1:34 AM, Stanislav Blinov wrote:
>> 12.10.2010 17:52, Justin Johansson пишет:
>>> 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
>>>
>>
>> writeln(typeid(typeof(null))) yields void* :)
>>
>
> Are you suggesting that the type of "null" is
> opaque or merely saying what the D compiler says
> without an opinion?
>
There was a smile there, no? Alright, alright, joking mood off.

Personally, I'd suggest that null has no 'type' by itself, but adapts to 
whatever type is applicable in certain use case. It may be viewed as if 
D had several different 'nulls' for every existing and user-defined 
reference type.


More information about the Digitalmars-d mailing list