Memory safe in D

Walter Bright newshound2 at digitalmars.com
Tue Mar 12 03:00:24 UTC 2024


On 3/11/2024 3:20 AM, Alex wrote:
> Oh... looks like null is also used for refs in D. It's sad :)
> I thought it used only for pointers in unsafe mode.
> I think, the null safety feature is very important in modern world (maybe "must 
> have" :) ). Very nice to have such feature in D like in Kotlin for example.
> So, as I understand, D team have the task in TODO list about implementation 
> something like "null safety"?

Null is actually not a memory safety issue. What happens when null is read or 
written to is a seg fault. The seg fault is the hardware saying "you cannot do 
that", so there is nothing unsafe about it.

Memory safety is being unable to corrupt memory. The seg fault ensures no memory 
corruption happens.



More information about the Digitalmars-d mailing list