No, it's not the same feature at all. The composable records thing, allows an already defined record type to be anonymously added to another record, that's what causes the potential for naming conflicts. None of the things I suggested opens the door to ever having that problem because you can't simply add the layout of a previously defined record without naming it.
When a record is embedded anonymously, its fields enter the outer record's namespace. Duplicate names =
compile error, not silent shadowing. The embed is a literal include of the embedded record's content - the compiler walks both field lists, flags any clash, refuses to build.
Named embed is a separate form, also supported. With
name: TInner; the access goes through the carrier (
outer.name.field), and same field names in both records coexist fine - they're in different scopes.
Two options for two different intents:
- Anonymous embed (embed TInner;): flat access, shared namespace, compile error on collision
- Named embed (name: TInner;): scoped access through the carrier, namespaces stay separate by design
On the maintenance scenario -
TInner gains a field later that collides with something in
TOuter - that's a compile error on the next build, not a silent breakage. The maintainer is forced to deal with it the moment they pull the change. That's the failure mode you want: explicit, immediate, traceable. Not a "naming house of cards" - more like an early warning system.
So I don't see the structural problem you're flagging. If you've got a concrete scenario where it actually bites silently, I'd genuinely like to see it.
Still confused.