On 2013-10-09 18:14:31 +0000, Andrei Alexandrescu <[email protected]> said:

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.

I don't think that's on the reject list. Yah, call a function that may either be an inline lightweight refcount manipulation, or forward to a virtual method etc. It's up to the class.

Are we talking about the same thing? You say "it's up to the class", but it should be obvious that *everything* being reference counted (as I wrote above) means every pointer, not only those to classes. Having only classes being reference counted is not very helpful if one wants to avoid the garbage collector.

And that discussion with Johannes Pfau a few minutes ago about exceptions shows that if you disable the GC, exceptions can't depend on the GC anymore to be freed, which is a problem too. (Should we create another ref-counted exception root type? Hopefully no.)

In my opinion, trying to segregate between reference-counted and garbage-collected types just makes things awfully complicated. And it doesn't help much someone who wants to avoid the GC. To be useful, reference counting should be a replacement for the garbage collector (while still keeping the current GC to free cycles).

--
Michel Fortin
[email protected]
http://michelf.ca

Reply via email to