UDP enhancement

JS js.mdnq at gmail.com
Tue Jul 2 03:52:39 PDT 2013


On Tuesday, 2 July 2013 at 04:49:55 UTC, estew wrote:
>>>
>>> > 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.

Or just use the old way. Just because one extends a feature does 
not mean the old feature is removed. If you need to hack up the 
bits just explicitly allocate the field... simple as that.



More information about the Digitalmars-d mailing list