Introducing Nullable Reference Types in C#. Is there hope for D, too?
rumbu
rumbu at rumbu.ro
Fri Nov 17 05:50:24 UTC 2017
On Friday, 17 November 2017 at 02:25:21 UTC, codephantom wrote:
> On Friday, 17 November 2017 at 01:47:01 UTC, Michael V.
> Franklin wrote:
>>
>> It peeked my interested, because when I first started studying
>> D, the lack of any warning or error for this trivial case
>> surprised me.
>>
>> // Example A
>> class Test
>> {
>> int Value;
>> }
>>
>> void main(string[] args)
>> {
>> Test t;
>> t.Value++; // No compiler error, or warning. Runtime
>> error!
>> }
>
>
> Also, if you start with nothing, and add 1 to it, you still end
> up with nothing, cause you started with nothing. That makes
> completed sense to me. So why should that be invalid?
You are not ending with nothing, you are ending with a run time
error in D. In C# it's a compile-time error. Ideally, something
ending for sure in an error at run time, must be catch at
compile-time.
More information about the Digitalmars-d
mailing list