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