Skip to content

Commit 890311d

Browse files
committed
add with compound statement
1 parent a453ed8 commit 890311d

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

spec/statement.dd

+18-9
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ else
339339
//writeln(m.pre); // Error: undefined identifier 'm'
340340
---
341341
)
342-
)
343342

344343
$(H2 $(LEGACY_LNAME2 WhileStatement, while-statement, While Statement))
345344

@@ -1762,12 +1761,18 @@ object.)
17621761

17631762
$(GRAMMAR
17641763
$(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))
17681771
)
17691772

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:)
17711776

17721777
$(UL
17731778
$(LI a class reference)
@@ -1776,8 +1781,8 @@ $(GNAME WithStatement):
17761781
$(LI a pointer to one of the above)
17771782
)
17781783

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.
17811786

17821787
---
17831788
enum E { A, B }
@@ -1815,8 +1820,8 @@ with (expression)
18151820
}(expression);
18161821
--------------
18171822

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
18201825
$(D super) refer to.
18211826
)
18221827

@@ -1923,6 +1928,10 @@ void main()
19231928
// not implemented in `main`'s scope, so resolution is
19241929
// subsequently forward to module scope.
19251930
}
1931+
1932+
with(foo): // StatementList form
1933+
f(); // prints "Foo.f"
1934+
f(); // prints "Foo.f"
19261935
}
19271936
---
19281937
)

0 commit comments

Comments
 (0)