@@ -1762,12 +1762,18 @@ object.)
1762
1762
1763
1763
$(GRAMMAR
1764
1764
$(GNAME WithStatement):
1765
- $(D with) $(D $(LPAREN)) $(EXPRESSION) $(D $(RPAREN)) $(PSSCOPE)
1766
- $(D with) $(D $(LPAREN)) $(GLINK2 template, Symbol) $(D $(RPAREN)) $(PSSCOPE)
1767
- $(D with) $(D $(LPAREN)) $(GLINK2 template, TemplateInstance) $(D $(RPAREN)) $(PSSCOPE)
1765
+ $(GLINK WithClause) $(PSSCOPE)
1766
+ $(GLINK WithClause) : $(GLINK StatementList)
1767
+
1768
+ $(GNAME WithClause):
1769
+ $(D with) $(D $(LPAREN)) $(EXPRESSION) $(D $(RPAREN))
1770
+ $(D with) $(D $(LPAREN)) $(GLINK2 template, Symbol) $(D $(RPAREN))
1771
+ $(D with) $(D $(LPAREN)) $(GLINK2 template, TemplateInstance) $(D $(RPAREN))
1768
1772
)
1769
1773
1770
- where *Expression* evaluates to one of:
1774
+ $(P The *StatementList* form is equivalent to the *ScopeStatement* form.)
1775
+
1776
+ $(P *Expression* evaluates to one of:)
1771
1777
1772
1778
$(UL
1773
1779
$(LI a class reference)
@@ -1776,8 +1782,8 @@ $(GNAME WithStatement):
1776
1782
$(LI a pointer to one of the above)
1777
1783
)
1778
1784
1779
- Within the with body the referenced object is searched first for
1780
- identifier symbols.
1785
+ Within the ` with` $(I ScopeStatement) or $(I StatementList) the referenced object is
1786
+ searched first for identifier symbols.
1781
1787
1782
1788
---
1783
1789
enum E { A, B }
@@ -1815,8 +1821,8 @@ with (expression)
1815
1821
}(expression);
1816
1822
--------------
1817
1823
1818
- $(P Note that *Expression* only gets evaluated once and is not copied.
1819
- The with statement does not change what $(D this) or
1824
+ $(NOTE *Expression* only gets evaluated once and is not copied.
1825
+ The *WithStatement* does not change what $(D this) or
1820
1826
$(D super) refer to.
1821
1827
)
1822
1828
@@ -1923,6 +1929,10 @@ void main()
1923
1929
// not implemented in `main`'s scope, so resolution is
1924
1930
// subsequently forward to module scope.
1925
1931
}
1932
+
1933
+ with(foo): // StatementList form
1934
+ f(); // prints "Foo.f"
1935
+ f(); // prints "Foo.f"
1926
1936
}
1927
1937
---
1928
1938
)
0 commit comments