On Sunday, 1 March 2015 at 17:03:46 UTC, ketmar wrote:
On Sun, 01 Mar 2015 15:53:06 +0000, Marc Schütz wrote:
However, AFAICS, it comes with a serious problem. Immutable
objects are
freely passable between threads, so surely an immutable RC
object would
need atomic counting just like a shared RC object, but unlike
shared,
immutable does not necessarily express the intent of sharing
between
threads; the immutable RC object could easily be counting
atomically
for nothing.
Argh! I didn't think about this. Any chance we can deprecate
this
behaviour? It's also an obstacle for the implementation of
thread-local
heaps.
but deprecating this is... illogical at best. immutable objects
are
immutable, so why can't i pass 'em to any thread? do you mean
that i
can't use `immutable string = "mystr";` in different threads
without
copying anymore?
Don't know. It was more of a question than a recommendation. It
might be impractical.
OTOH, I don't think it's illogical, because thread-locality and
immutability are independent concepts. There can be shared
mutable data (`shared`) as well as thread-local immutable data.
Hmm... that would be equivalent to `const`, no? But that's
getting off-topic.