On Thu, 23 Jul 2009 13:10:59 -0400, Jarrett Billingsley <[email protected]> wrote:

On Thu, Jul 23, 2009 at 12:11 PM, Rainer Deyke<[email protected]> wrote:

Yes, C++ has problems, but these problems can be fixed!  The
struct/class split, on the other hand, introduces many more problems
that are harder to fix.

You know, this is like the first thing C++ users complain about on the
IRC channel when they find D: "what if I want to turn a class into a
struct, or vice versa?"

I've been using D for five years, and I have never.

EVER.

Needed or desired to do that.  Nor have I heard anyone but new C++
users complaining about it.

I did.

With dcollections, my nodes were classes at first, because they were supposed to be heap-allocated reference types.

However, when I realized that with a custom allocator, I could tremendously increase performance, I had to switch to structs.

What ended up happening is I simply aliased Node to node *, and that was that. Come to think of it, I probably didn't put enough thought in my choice of classes to begin with.

This however, is not a true "change" since I just changed classes to struct references, not to actual value type structs.

I plan on doing some more class-to-struct changes, not sure how it will pan out.

But I think it certainly does come up that choosing struct or class is not an easy decision, and both can have advantages/disadvantages.

However, I don't think C++ solves that problem very well either.

The one thing I think is missing from D in this area is struct interfaces.

-Steve

Reply via email to