GC and void*
schveiguy at yahoo.com
Thu Jan 26 07:38:25 PST 2012
On Wed, 25 Jan 2012 19:11:36 -0500, Nicolas Silva <nical.silva at gmail.com>
> I need to be sure: would the GC collect an object that is still reachable
> through a void* pointer ?
No. The current GC does not know anything about type information. It
blindly assumes if a pointer points to some block of data, that block of
data is still in use.
> Also, is there a big difference between casting from Object to T and
> casting from void* to T* ?
Well, first of all, what is T? If T is a class, you would not cast void *
to T*, you almost never use T* since T is already a reference. You could
cast void * to T.
Casting Object to T if T is a class is going to be a dynamic cast,
returning null if the object in question is not actually a T. If you know
it is a T, then doing a cast to void * first, then to T will circumvent
the dynamic cast.
> I mean in term of speed. It looks like could be the same difference as
> between C++'s dynamic_cast and static_cast but i'd like to be sure as
More information about the Digitalmars-d-learn