What's the D equivalence?
Imperatorn
johan_forsberg_86 at hotmail.com
Sat Mar 6 14:44:36 UTC 2021
On Saturday, 6 March 2021 at 12:15:16 UTC, Nick Treleaven wrote:
> On Saturday, 6 March 2021 at 11:52:41 UTC, Imperatorn wrote:
>> On Saturday, 6 March 2021 at 11:48:37 UTC, Nick Treleaven
>> wrote:
>>> f(*p); // at least if p is accidentally null, it will crash
>>> here, right? nope
>>> }
>>>
>>> This could be fixed by checking for null in @safe code when
>>> dereferencing a pointer passed to a `ref` parameter. But that
>>> doesn't fix the unsafety of the sowChaos example (although at
>>> least that isn't so confusing).
>>
>> To summarize, am I safe if I always null check? 🤔
>
> How do you ensure every pointer dereference is guarded by a
> null check? I think you would need a tool to ensure that (or
> insert the checks for you).
I'm used to just doing it manually when needed, just like I
null-check my objects in c# before accessing some property for
example.
More information about the Digitalmars-d
mailing list