[OT] OT: Null checks.

Walter Bright newshound2 at digitalmars.com
Tue May 6 23:34:37 UTC 2025


On 5/5/2025 8:38 PM, Timon Gehr wrote:
> On 5/6/25 05:31, Timon Gehr wrote:
>>
>> I just wish everyone would refrain from actively putting invalid instructions 
>> and segfaults into druntime in the future. They are not _that_ useful and 
>> there are vastly more useful alternatives. x)
> 
> And the same is true for segfault-on-null. I don't want this. If a standard null 
> check can be implemented taking advantage of CPU features, fine. But semantics 
> should be the same as if the compiler inserted a branch that throws an error 
> every time a nullable pointer is dereferenced.

That's an awful lot of test and branch code being unnecessarily inserted to 
test-and-throw instead of segfault-and-throw, because that's what a segfault is 
- a thrown exception.


> Even better would be the type system just ensuring nullable pointers are never 
> dereferenced, the OP's experience report notwithstanding. But I guess this part 
> is a pipe dream for now.

Have you tried using a template to achieve that?


More information about the Digitalmars-d mailing list