[RFC] Throwing an exception with null pointers

Walter Bright newshound2 at digitalmars.com
Wed Apr 16 21:12:08 UTC 2025


On 4/16/2025 12:57 PM, Dave P. wrote:
> You put a `#pragma clang 
> assume_nonnull begin` at the top of your C/C++/Objective-C code and you have to 
> annotate only the nullable pointers. Most pointers in a program should be 
> non-null and the nullable ones should be the exception that you have to annotate.

Annotation means more than one pointer type.

Back in the old MSDOS days, there were 5 pointer types - near, far, stack, code 
and huge. Dealing with that is a gigantic mess - which pointer type does 
strlen() take? Or worse, strcpy()?

Microsoft's Managed C++ has two pointer types with different syntax, a GC 
pointer and a non-GC pointer. The same problem - what pointer type does strcpy() 
accept?

It's an ugly mess, and why I've avoided any such thing in D.

I'm curious - how does one traverse a binary tree with non-null pointers? How 
does one create a circular data structure with non-null pointers?


More information about the Digitalmars-d mailing list