Prototype of Ownership/Borrowing System for D

Johannes Pfau nospam at example.com
Fri Nov 22 08:08:07 UTC 2019


Am Thu, 21 Nov 2019 20:55:57 -0800 schrieb Walter Bright:

> 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"

But only if you don't know for sure already that the pointer can't 
possibly be null. With non-null types (by default) such situations are 
rare.

You should really have a look at TypeScript / Kotlin some time. In 
Javascript, aborting scripts due to null-pointers in untested codepaths 
has be a main reason of bugs and TypeScript really nicely solved this. I 
think non-null types + these automated conversion from nullable to non-
null are the most important innovations for OOP code in recent years and 
the feature i miss most when doing OOP in D.

-- 
Johannes


More information about the Digitalmars-d mailing list