Sending an immutable object to a thread

anonymous via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 24 22:44:14 PDT 2015


On Friday, 24 July 2015 at 21:51:44 UTC, Frank Pagliughi wrote:
> So then: is there a pointer notation to which you can cast the 
> "B" reference, which thus points to the heap, but retains type 
> identity of the heap object?

There's no straight forward way to do that. D has no types for 
the actual objects of classes. You'd have to generate a new 
struct type from B that you can point at.

>
> And the reason I ask if I wanted to declare a type which is a 
> mutable pointer to an immutable object that is on the GC heap, 
> keeping type info? Or is the answer, "no", just use Rebindable 
> when necessary?

We only have Rebindable because there is no nice way in the 
language to do it. So, just use Rebindable, yes.

You could look at what Rebindable does, and then do that, of 
course. But be sure that you understand all the nasty details.


More information about the Digitalmars-d-learn mailing list