I think I understand (and admire) D's use of value semantics for structs and reference semantics for classes. I believe classes exist for the entirety of a program's life whereas structs exist for the lifetime of their scope.

So I assume it is illegal for a struct to contain a class? And (holding my nose) pointers too? In Andrei's Book he writes "a struct is just a glorified int".

However, it would be quite ok for a class to contain a struct?

Does a fixed-length, static array behave with value semantics while a dynamic array behave with reference semantics?


And then what to make of Phobos' std.container, when it says "DList uses neither reference nor value semantics." Is there some hybrid or new undiscovered semantic I've never heard about?

Thanks for suffering this fool gladly.

Reply via email to