UDP enhancement

estew estewh at gmail.com
Mon Jul 1 21:49:54 PDT 2013


>>
>> > It's location in the class my not be the same but that is, in
>> > general, irrelevant unless you are messing with the bits of
>> the class.
>>

Actually we do this a lot in C++ where I work to ensure proper 
alignment. We are also starting to do this in D where we have C++ 
<-> D bindings so we can make our D structs exactly match our C++ 
structs in memory.

Personally I see less benefit over:

public @property int value;

This approach is nice. It can be used both when layout is 
important and when it is "don't care" and is clearer. I can look 
at the struct and immediately read its memory footprint.

Your suggested proposal cannot be used when layout is important 
as it is left to the compiler. It would require a workaround to 
coerce the compiler into submission, or additional compiler 
circuitry making it even more complex and slowing it down.





More information about the Digitalmars-d mailing list