ralferoo 6 days ago

I don't use Zig, but one advantage of having a genericised intrusive linked list where the next pointer doesn't have to be the first thing in the structure is when you want to use larger types, such as 128-bit fields. Sticking a pointer at the beginning would mean the compiler would have to insert alignment padding after the pointer or break the default alignment.

1
jwmerrill 6 days ago

The next pointer doesn’t have to go first in the structure here. It can go anywhere, and you can use @fieldParentPtr to go back from a reference to the embedded node to a reference to the structure.

n42 6 days ago

I think that's the point the parent was making. I read it as them describing a benefit of Zig's approach.

ralferoo 5 days ago

Yeah, that's what I was trying to say, but obviously not clearly enough.

jwmerrill 5 days ago

My mistake! It seems clear in hindsight…