On 10/5/2011 6:25 AM, deadalnix wrote:
I see two solutions to deal with this :

Something allocated on a Thread local heap can be seen from other threads, and
this is safe as long as a reference is kept in the allocating thread.

So, if you cast something TL and mutable as immutable, you have to ensure
yourself that you will not modify it. Plus, you need to ensure that you keep a
reference on that object in the allocating thread, otherwise, you'll see it
collected.

A shared casted as immutable should exprience any issue.

The other apporach is to give a way to explicitely say to the compiler that this
will be casted as shared/immutable at some point and should be allocated on the
corresponding heap.

Thoses two solutions are not exclusives and can be both implemented. Maybe I'm
wrong, but it doesn't seems that the issue is that big.

Both your solutions can work, but they can be highly error prone as they rely on the programmer getting the details right, and there's little means to verify that they did get them right.

Reply via email to