Memory safe in D
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Mon Mar 11 10:45:27 UTC 2024
On 11/03/2024 11:39 PM, Alex wrote:
> On Monday, 11 March 2024 at 10:31:05 UTC, Richard (Rikki) Andrew
> Cattermole wrote:
>> On 11/03/2024 11:20 PM, 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"?
>>
>> I'm not sure I'd call myself part of the core D team (although I have
>> another proposal that is currently going through the DIP process that
>> would certainly qualify me for the title!).
>>
>> However in saying that, memory safety is on the foundation's radar as
>> needing solving.
>>
>> I'm just the weirdo that is having a go at trying to solve temporal
>> memory safety (an unsolved problem!).
>
> Thank you for the information!
> Maybe you know: are there some guys from D foundation here?
Yes, they are around including Walter, I'm sure he'll see it within the day.
> Also, I figured out that I can't handle uninitialized access via try/catch:
>
> ```d
> A a;
> try {
> a.run();
> } catch(Throwable) {
> writeln("Error");
> }
> ```
>
> So the catch branch not work here.
The a variable was initialized, via default initialization.
It is in a known state, null.
What you are wanting is a way to have the compiler complain when a
nonnull type state is expected, but it is initialized.
D does not support that currently.
More information about the Digitalmars-d
mailing list