On Wednesday, 13 November 2019 at 11:07:12 UTC, IGotD- wrote:
I'm trying to find the rationale why GC pointers (should be names managed pointers) are using the exact same type as any other pointer.

Doesn't this limit the ability to change the default GC type?
What does grabage collector type mean?

Doesn't this confusion make GC pointers just as unsafe as raw pointers?
It does if you pass the pointers to somewhere the garbage collector does not know about. However, normally it has a list of all memory used by the program -even the memory that is not managed by it. But if you, for example, put a pointer to memory allocated by some C program that is totally unaware of the GC, you need to either manually register (and unregister) the memory to the GC, or keep a copy of the pointer in somewhere the GC knows about. Assuming the pointed memory is controlled by GC, that is. Otherwise, the GC will not find the pointer during collection and think you have stopped using the memory it points to.

Has there been any prior discussion about introducing managed pointers in D?
I'm not 100% sure what managed pointers mean -Are they so that you can't pass them to unregistered memory? A library solution would likely do -wrap the pointer in a struct and make it @system to extract it's pointer as "raw". So you cannot put it to C-allocated arrays without type casting, which you probably don't do accidently.

Reply via email to