Can non-nullable references be implemented as a library?
Simen kjaeraas
simen.kjaras at gmail.com
Sun Nov 7 09:29:03 PST 2010
Simen kjaeraas <simen.kjaras at gmail.com> wrote:
> Denis Koroskin <2korden at gmail.com> wrote:
>
>> Since many people think that non-nullable references can be implemented
>> as a library and thus don't belong to core language, I've decided to
>> show that it is in fact impossible to do so.
>>
>> How do you enforce the following behavior:
> [snip]
>>
>> Without support of these use-cases NonNull!(T) is useless.
>>
>> There can be other examples, but I think these are enough to prove that
>> non-nullable references can not be implemented in library.
>
> Indeed. There is also the arrays I've mentioned before, and as you
> mention here, fields of classes and structs. Good catch.
Worth adding:
Even if non-null references/pointers cannot be perfectly implemented in a
library, they may still be a worthwhile addition to Phobos, to mark
function arguments and the like.
--
Simen
More information about the Digitalmars-d
mailing list