New abstraction: Layout
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sat Feb 17 12:49:07 UTC 2018
On 02/16/2018 10:10 PM, rikki cattermole wrote:
> On 17/02/2018 12:04 AM, Andrei Alexandrescu wrote:
>> I've been long bothered that the builtin .tupleof and our own
>> abstractions Fields and RepresentationTypeTuple in std.traits - all
>> omit the essential information of field offsets. That makes types that
>> use align() to have the same .tupleof, Fields, and
>> RepresentationTypeTuple even though they shouldn't.
>>
>> The right answer is Layout a tuple of (offset, type) pairs describing
>> entirely the memory layout of a type. We need such for memory
>> allocation, garbage collection, serialization, and more.
>>
>> The implementation turned out to be quite compact - 81 lines including
>> a compile-time mergesort. Destroy!
>>
>> https://github.com/dlang/phobos/pull/6192
>>
>>
>> Andrei
>
> Could use the name for the field as well. At the minimum useful for
> debugging purposes.
That would be tricky because fields are decomposed down to primitive
types. -- Andrei
More information about the Digitalmars-d
mailing list