3 ms·
Is this mentioned in the spec anywhere? That piece of information was precisely what I was looking for, but wasn't able to find.
by kibwen 11y ago
Is this mentioned in the spec anywhere? That piece of information was precisely what I was looking for, but wasn't able to find.
- masklinn 11y agoThe spec doesn't define field ordering anywhere, which is why it's undefined. Russ Cox commented on the bug I linked essentially confirming it: > It seems fine to me for the spec not to guarantee anything about struct field order in memory. The spec doesn't operate at that level. And while he adds > That said, no Go compiler should probably ever reorder struct fields. the final result is struct memory layout is unspecified and implementation-dependent (essentially identical to repr(rust), as I understand it)
- kibwen 11y agoThe intent of a specification is to be explicit, and in doing so it's poor form to say "this is undefined, so we're simply not going to mention it in the spec at all". If it's undefined then the spec should say so, especially if the alternative is for one to cast about in confusion until hopefully stumbling across the relevant documentation in, of all places, the bug tracker.