On 2013-10-09 11:58:33 +0000, Jacob Carlborg <[email protected]> said:
On 2013-10-09 09:33, Manu wrote:
It sounds pretty easy to reach to me. Compiler generating inc/dec ref
calls can't possibly be difficult. An optimisation that simplifies
redundant inc/dec sequences doesn't sound hard either... :/
Is there more to it? Cleaning up circular references I guess... what
does Apple do?
It's an uncommon edge case, so there's gotta be heaps of room for
efficient solutions to that (afaik) one edge case. Are there others?
See my reply to one of your other posts:
http://forum.dlang.org/thread/[email protected]?page=10#post-l33gah:24ero:241:40digitalmars.com
I
don't recall the exact issues but there were several issues that were
brought up in the email conversation.
Here's a quick summary:
Walter's idea was to implement ARC for classes implementing IUnknown.
So if you wanted a ARC'ed class, you implement IUnknown and you're
done. Problems were on the edges of ARC-controlled pointers and
GC-controlled ones (which cannot be allowed to be mixed), and also with
wanting to use the GC to free cycles for these objects (which would
make COM AddRef and Release unusable when called from non-D code). I
think the only way to make that work sanely is to create another root
object for ref-counted classes.
Another idea was to make *everything* in D ref-counted. ARC simply
becomes another GC implementation. There can be no confusion between
what's ref-counted and what isn't (everything is). It's much simpler
really. But Walter isn't keen on the idea of having to call a function
at every pointer assignment to keep the reference count up to date (for
performance reasons), so that idea was rejected. This makes some sense,
because unlike Objective-C ARC where only Objective-C object pointers
are ref-counted, in D you'd have to do that with all pointers, and some
will point to external data that does not need to be ref-counted at all.
It was also pointed out that concurrent GCs require some work to be
done on pointer assignment (and also when moving a pointer). So it
seems to me that advances on the GC front are going to be limited
without that.
And now, things seems to have stalled again. It's a little disappointing.
--
Michel Fortin
[email protected]
http://michelf.ca