New abstraction: Layout

Jonathan M Davis newsgroup.d at jmdavisprog.com
Wed Feb 21 06:00:59 UTC 2018


On Wednesday, February 21, 2018 05:53:31 Basile B. via Digitalmars-d wrote:
> On Saturday, 17 February 2018 at 00:04:16 UTC, 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
>
> how does this deal with static members ?

It's built on tupleof, so it doesn't do anything with static members. But
static members have nothing to do with the layout of a type, so it wouldn't
make sense for it to do anything with static members.

- Jonathan M Davis



More information about the Digitalmars-d mailing list