Prototype of Ownership/Borrowing System for D

Sebastiaan Koppe mail at
Fri Nov 22 07:33:01 UTC 2019

On Friday, 22 November 2019 at 04:55:57 UTC, Walter Bright wrote:
> On 11/21/2019 4:28 AM, Jacob Carlborg wrote:
>> On Thursday, 21 November 2019 at 11:10:28 UTC, Walter Bright 
>> wrote:
>>> I would find that to be annoying, as the CPU hardware checks 
>>> it before dereferencing it, too, for free.
>> Why would you wait until runtime when the compiler can do it 
>> at compile time?
> The antecedent said "it forces you to check a pointer
> before you dereference it"

I think that is looking at it from the wrong angle.

The power of optional types is being able to declare a 
non-optional type.

I have done a lot of Kotlin programming the last 2 years. The 
beauty is that when I see a T, I know it cannot be null. I know 
the compilers knows that, and I know my colleagues know that as 

If you don't want the check, just use T. If you cannot use T 
(because you might need it to be null), use T?, and then you need 
the check. The point is, in the case you end up using T?, you 
needed the check regardless.

As an example, just like to need to check whether a range isn't 
empty before you front it, the first() function in Kotlin 
(defined on collections) returns a T?, which needs to be checked 
before usage. But again, you needed that anyways.

More information about the Digitalmars-d mailing list