Why same pointer type for GC and manual memory?

Kagamin spam at here.lot
Thu Nov 14 15:29:33 UTC 2019


On Wednesday, 13 November 2019 at 16:43:27 UTC, IGotD- wrote:
> On Wednesday, 13 November 2019 at 15:30:33 UTC, Dukc wrote:
>>
>> 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.
>>
>
> Best example is probably managed C++, an MS extension to C++ 
> which is now deprecated. However, it server as an interesting 
> example where MS extended C++ with a ^gc type.

AFAIK those managed pointers are not general purpose, but 
specifically for managed .net objects, you can't allocate 
unmanaged object on managed heap, and managed object on unmanaged 
heap. In case of D you would have raw pointers for unmanaged 
objects allocated in C heap and D GC heap, and additional .net 
pointers for .net objects.


More information about the Digitalmars-d-learn mailing list