Memory safe in D

Steven Schveighoffer schveiguy at gmail.com
Thu Mar 14 02:09:15 UTC 2024


On Wednesday, 13 March 2024 at 20:34:42 UTC, Alex wrote:
> On Wednesday, 13 March 2024 at 19:58:24 UTC, Steven 
> Schveighoffer wrote:
>> Having a possibly-null pointer is no different. D defines that 
>> in safe code, a pointer will be valid or null. The "check" 
>> occurs on use, and is performed by the hardware.
>
> But the fundamental difference that null pointer checks is 
> performed in D at runtime but in Kotlin (and other languages 
> which support null safety) at compilation time.

No, Kotlin also performs a check at runtime. The same hardware 
runs the machine code, and the MMU is the same one that runs D 
code.

However, the check is not considered to cost anything. It's part 
of how the MMU works.

-Steve


More information about the Digitalmars-d mailing list