Skip to content

Commit 956026b

Browse files
committed
add with compound statement
1 parent a453ed8 commit 956026b

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

spec/statement.dd

+18-8
Original file line numberDiff line numberDiff line change
@@ -1762,12 +1762,18 @@ object.)
17621762

17631763
$(GRAMMAR
17641764
$(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))
17681772
)
17691773

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

17721778
$(UL
17731779
$(LI a class reference)
@@ -1776,8 +1782,8 @@ $(GNAME WithStatement):
17761782
$(LI a pointer to one of the above)
17771783
)
17781784

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

17821788
---
17831789
enum E { A, B }
@@ -1815,8 +1821,8 @@ with (expression)
18151821
}(expression);
18161822
--------------
18171823

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
18201826
$(D super) refer to.
18211827
)
18221828

@@ -1923,6 +1929,10 @@ void main()
19231929
// not implemented in `main`'s scope, so resolution is
19241930
// subsequently forward to module scope.
19251931
}
1932+
1933+
with(foo): // StatementList form
1934+
f(); // prints "Foo.f"
1935+
f(); // prints "Foo.f"
19261936
}
19271937
---
19281938
)

0 commit comments

Comments
 (0)