disable broken tests on net_4_0
[mcs.git] / docs / ecma334 / 16.2.xml
blobab379d3f861c6b2d092d549faa292bd4c29e293a
1 <?xml version="1.0"?>
2 <clause number="16.2" title="Namespace declarations">
3   <paragraph>A <non_terminal where="16.2">namespace-declaration</non_terminal> consists of the keyword namespace, followed by a namespace name and body, optionally followed by a semicolon. <grammar_production><name><non_terminal where="16.2">namespace-declaration</non_terminal></name> : <rhs><keyword>namespace</keyword><non_terminal where="16.2">qualified-identifier</non_terminal><non_terminal where="16.2">namespace-body</non_terminal><terminal>;</terminal><opt/></rhs></grammar_production><grammar_production><name><non_terminal where="16.2">qualified-identifier</non_terminal></name> : <rhs><non_terminal where="9.4.2">identifier</non_terminal></rhs><rhs><non_terminal where="16.2">qualified-identifier</non_terminal><terminal>.</terminal><non_terminal where="9.4.2">identifier</non_terminal></rhs></grammar_production><grammar_production><name><non_terminal where="16.2">namespace-body</non_terminal></name> : <rhs><terminal>{</terminal><non_terminal where="16.3">using-directives</non_terminal><opt/><non_terminal where="16.4">namespace-member-declarations</non_terminal><opt/><terminal>}</terminal></rhs></grammar_production></paragraph>
4   <paragraph>A <non_terminal where="16.2">namespace-declaration</non_terminal> may occur as a top-level declaration in a <non_terminal where="16.1">compilation-unit</non_terminal> or as a member declaration within another <non_terminal where="16.2">namespace-declaration</non_terminal>. When a <non_terminal where="16.2">namespace-declaration</non_terminal> occurs as a top-level declaration in a <non_terminal where="16.1">compilation-unit</non_terminal>, the namespace becomes a member of the global namespace. When a <non_terminal where="16.2">namespace-declaration</non_terminal> occurs within another <non_terminal where="16.2">namespace-declaration</non_terminal>, the inner namespace becomes a member of the outer namespace. In either case, the name of a namespace must be unique within the containing namespace. </paragraph>
5   <paragraph>Namespaces are implicitly public and the declaration of a namespace cannot include any access modifiers. </paragraph>
6   <paragraph>Within a <non_terminal where="16.2">namespace-body</non_terminal>, the optional <non_terminal where="16.3">using-directive</non_terminal>s import the names of other namespaces and types, allowing them to be referenced directly instead of through qualified names. The optional  <non_terminal where="16.4">namespace-member-declaration</non_terminal>s contribute members to the declaration space of the namespace. Note that all  <non_terminal where="16.3">using-directive</non_terminal>s must appear before any member declarations. </paragraph>
7   <paragraph>The <non_terminal where="16.2">qualified-identifier</non_terminal> of a <non_terminal where="16.2">namespace-declaration</non_terminal> may be a single identifier or a sequence of identifiers separated by &quot;.&quot; tokens. The latter form permits a program to define a nested namespace without lexically nesting several namespace declarations. <example>[Example: For example, <code_example><![CDATA[
8 namespace N1.N2  
9 {  
10    class A {}  
11    class B {}  
12 }  
13 ]]></code_example>is semantically equivalent to <code_example><![CDATA[
14 namespace N1  
15 {  
16    namespace N2  
17    {  
18       class A {}  
19       class B {}  
20    }  
21 }  
22 ]]></code_example>end example]</example> </paragraph>
23   <paragraph>Namespaces are open-ended, and two namespace declarations with the same fully qualified name contribute to the same declaration space (<hyperlink>10.3</hyperlink>). <example>[Example: In the example <code_example><![CDATA[
24 namespace N1.N2  
25 {  
26    class A {}  
27 }  
28 namespace N1.N2  
29 {  
30    class B {}  
31 }  
32 ]]></code_example>the two namespace declarations above contribute to the same declaration space, in this case declaring two classes with the fully qualified names N1.N2.A and N1.N2.B. Because the two declarations contribute to the same declaration space, it would have been an error if each contained a declaration of a member with the same name. end example]</example> </paragraph>
33 </clause>