There would have been a certain elegance to regarding a struct as a
scope, and struct member selects as simply another form of hierarchical
reference into that struct scope. However, I don't believe that the LRM
has done that. Structs are not defined to be scopes in the LRM.
I don't think the LRM actually says that the same member name can be
re-used for a different struct type. We all assume it automatically, from
our experience with other languages. Even after we accept this as true,
it does not mean that it comes from a general rule about scopes as applied
to structs. Since structs are not defined to be scopes, it would have to
come from a more specific (unwritten) rule about structs.
Since the feature and most of its syntax and semantics came from C, we
can also compare this aspect to C. I did some testing with gcc to check
that my understanding of this was correct. In C, different structs can have
members with the same name. However, a struct is not a scope. If this
same kind of anonymous enum declaration is done in C, the enum constants
are visible outside the struct. If a second struct is declared with the
same anonymous enum names inside it, this produces an error for redeclaring
the same name.
Steven Sharp | Architect | Cadence
P: 508.459.1436 M: 774.535.4149 www.cadence.com
-- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Fri May 14 11:58:04 2010
This archive was generated by hypermail 2.1.8 : Fri May 14 2010 - 12:00:53 PDT