On Fri, 04 May 2012 13:09:06 -0400, Jonathan M Davis <jmdavisp...@gmx.com> wrote:

On Friday, May 04, 2012 11:47:31 Steven Schveighoffer wrote:
Yes, a struct can do reference semantics, but it makes little sense to
fight the type system and shoehorn it into reference semantics, when
classes are reference types by default.

A struct makes a lot more sense than a class when you need deterministic
destruction. IIRC, the last time that it was discussed, it was decided that we'd go with structs rather than classes, because it would work better with
custom allocators, but it was a rather involved discussion, and I don't
remember all of the details.

Allocation and destruction are orthogonal to the problem. For example, in working on the new std.io, I've had to make RefCounted!(class) work, All I do is allocate the class data into the C heap.

The issue is, do you want pass by reference, or pass by value. My opinion is that it should always be pass by reference for container types. And classes make that *so* much easier.

With structs, you have to jump through hoops to get them to properly be reference types.

-Steve

Reply via email to