On 04/17/2014 08:55 AM, Manu via Digitalmars-d wrote:
It occurs to me that a central issue regarding the memory management
debate, and a major limiting factor with respect to options, is the fact
that, currently, it's impossible to tell a raw pointer apart from a gc
pointer.

Is this is a problem worth solving? And would it be as big an enabler to
address some tricky problems as it seems to be at face value?

What are some options? Without turning to fat pointers or convoluted
changes in the type system, are there any clever mechanisms that could
be applied to distinguish managed from unmanaged pointers.

It does not matter if changes to the type system are 'convoluted'. (They don't need to be.)

If an API
could be provided in druntime, it may be used by GC's, ARC, allocators,
or systems that operate at the barrier between languages.


There already is.

bool isGCPointer(void* ptr){
    import core.memory;
    return !!GC.addrOf(ptr);
}

void main(){
    import std.c.stdlib;
    auto x=cast(int*)malloc(int.sizeof);
    auto y=new int;
    assert(!x.isGCPointer() && y.isGCPointer());
}

Reply via email to