Subject: Re: [sv-bc] Namespace issue w. struct/union member names?
From: Arturo Salz (Arturo.Salz@synopsys.com)
Date: Wed Oct 29 2003 - 12:29:21 PST
Nikhil,
See my comments below.
Arturo
----- Original Message -----
From: "Rishiyur S. Nikhil" <nikhil@bluespec.com>
To: <sv-bc@eda.org>
Sent: Wednesday, October 29, 2003 11:24 AM
Subject: [sv-bc] Namespace issue w. struct/union member names?
I have a question re. "18.9 Name spaces".
Do the member names in each struct/union also belong to a separate namespace?
[Arturo] I belive the correct term here is scope, not namespace.
And, the answer is yes; a struct/union creates a separate scope.
- Can we have a struct member called 'x' in the same scope as
something else named 'x' (say, a variable)?
[Arturo] Yes.
- Can 'x' be a member name in two separate structs or unions?
[Arturo] Yes.
I am assuming the answer to both questions is "yes", following C/C++,
but I can't seem to find the answers in the LRM.
If the answer is 'yes', then should Section 18.9 list each struct or
union definition as also introducing a new name space?
[Arturo] No, I don't think so. The LRM should mention in section 3.11 that
struct and unions create a scope. Section 18 discusses hierarchical
structure, and defines the varios namespaces, not declaration scopes.
I think this is a name space issue and not a scope issue. For
example, in the expressions:
x.x (i.e., variable.member)
{ x : x } (i.e., a struct expression)
the two x's in each expr (which are in the same scope) are resolved
differently. In the first expr the first x is a variable and the
second is a struct member name, and in the second expr the opposite is
true.
[Arturo] Strictly speaking, you are probably right, but name-spaces have
a somewhat different definition in Verilog. The whole discussion of name-
spaces, which is inherited from 1364, can use some work. I'm afraid that
talking of scopes and namespaces in tihs manner without reworking that
section will create much more confusion.
And: is there a similar question with class property and method names?
[Arturo] No. Section 11.21 mentions that classes are scopes. Both propeties and
methods share the same scope. Therefore, It is an error for a class to include the
a property and a method of the same name.
Nikhil
This archive was generated by hypermail 2b28 : Wed Oct 29 2003 - 12:31:44 PST