On Sun, 18 Dec 2011 01:15:40 -0500, Andrei Alexandrescu
<seewebsiteforem...@erdani.org> wrote:
On 12/17/11 7:52 PM, Jonathan M Davis wrote:
The only reason that I can think of to use a reference-counted struct
instead
of a class is becuse then it's easier to avoid the GC heap entirely.
Almost
all of a container's memory is going to end up on the heap regardless,
because
the elements almost never end up in the container itself.
Being on the heap is not the main issue. The main issue is the data
becoming garbage once all references are gone.
This whole thread of discussion is somewhat more complicated than it has
to be.
A ref-counted type is implemented via a reference to allocated data. That
data can be a class instance or a struct pointer.
Using a reference style struct just introduces problems you don't have to
worry about with a class. It gains you nothing except having to crowbar
the language into believing your struct is really a reference type.
And that's really hard to do.
-Steve