Difference (last change) (no other diffs, normal page display)
There is a limited constructor-type interface: See "static initialization of structs"|
The ability to specify alignment is mentioned but the syntax for doing so is not given. As far as I can tell you prefix the struct or union with the alignment requirements using align(n). So to get a struct where all members are 1-byte aligned you would do:
.sizeof is undocumented for unions
Details on how structures are passed into and out of functions would be useful. Are they defaultly passed by value? Are they returned by value? There is a comment that suggests you should not use structs as properties because they are returned by reference. - BradBeveridge?
- As far as I know, they're always passed by value, no matter how big they are. -- BillBaxter
For POD-types constructors can make code much more readable, take for example a struct to represent a 3D vector:
As I understand it, the main requirement is that structs and unions must be trivially copiable, so it would make sense that copy-constructors and copy-assignment-operators are disallowed, but constructors in general?
(corollary question: why is the assignment operator allowed for structs without this caveat?)
There is a limited constructor-type interface: See "static initialization of structs"
Put your comments about the official/non-official page here.
See the corresponding page in the D Specification: DigitalMars:d/struct