On Wednesday, 21 December 2011 at 07:30:45 UTC, Jonathan M Davis
wrote:
And if they're classes and not managed by the GC nor in a
struct which manages their lifetime, how are they going to be
freed? Does the user have to explicitly free them themselves?
How is that better than using a ref-counted struct?
Memory management should be the responsibility of the allocator
and it shouldn't be limited only to a single policy of
ref-counting which has many disadvantages.
And no, using reference semantics does _not_ require classes. A
class is just the easiest way to get reference semantics. It
doesn't necessarily mean that it's the best way. That depends
on the context.
- Jonathan M Davis
I didn't use the word 'require' anywhere, but it is indeed by far
the simplest and best way to define a ref-type. All I'm saying is
that when travelling from NYC to Washington DC through China, you
really should have good reasons to not use the direct route.