On Monday, 22 October 2012 at 11:06:50 UTC, Jacob Carlborg wrote:
On 2012-10-22 10:48, bearophile wrote:
This page says:
http://dlang.org/class.html
The D compiler is free to rearrange the order of fields in a
class to
optimally pack them in an implementation-defined manner.
Consider the
fields much like the local variables in a function - the
compiler
assigns some to registers and shuffles others around all to
get the
optimal stack frame layout. This frees the code designer to
organize
the fields in a manner that makes the code more readable
rather than
being forced to organize it according to machine optimization
rules.
Explicit control of field layout is provided by struct/union
types,
not classes.<
Ok, I didn't know that.
The order of the fields is rearranged for packing. Does that
affect the tupleof property? The example in
http://dlang.org/class.html for Class properties tulpleof seems
to implie that the the fields the returned Expression Tuple are
arranged in lexical order (i.e., as defined by the programmer in
the class definition). Is this always true for classes? What
about structs?