Skip to content

Commit c022f8d

Browse files
authored
[spec] Improve PostfixExpression docs (#3818)
* [spec] Improve PostfixExpression docs Add `.` and `(args)` entries in the operation table. List which type instances can be called. * Fix example
1 parent a535bf4 commit c022f8d

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

spec/expression.dd

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,16 +1591,23 @@ $(GNAME PostfixExpression):
15911591
)
15921592

15931593
$(TABLE
1594-
$(THEAD Operator, Description)
1595-
$(TROW `.`,
1594+
$(THEAD Operation, Description)
1595+
$(TROW `.` *Identifier*,
15961596
Either:
15971597
* Access a $(DDLINK spec/property, Properties, property) of a type or expression.
15981598
* Access a member of a module, package, aggregate type or instance, enum
15991599
or template instance.
16001600
* Call a free function using $(DDSUBLINK spec/function, pseudo-member, UFCS).
16011601
)
1602+
$(TROW `.` *NewExpression*, Instantiate a $(DDSUBLINK spec/class, nested-explicit,
1603+
nested class))
16021604
$(TROW `++`, Increment after use - see $(RELATIVE_LINK2 order-of-evaluation, order of evaluation))
16031605
$(TROW `--`, Decrement after use)
1606+
$(TROW `(args)`,
1607+
Either:
1608+
* Call an expression with optional arguments
1609+
* Construct a type with optional arguments
1610+
)
16041611
$(TROW *IndexOperation*, Select a single element)
16051612
$(TROW *SliceOperation*, Select a series of elements)
16061613
)
@@ -1623,14 +1630,26 @@ $(GNAME NamedArgument):
16231630
$(GLINK AssignExpression)
16241631
)
16251632

1626-
$(P A callable expression can precede a list of named arguments in parentheses.)
1633+
$(P A callable expression can precede a list of named arguments in parentheses.
1634+
The following expressions can be called:)
1635+
1636+
* A function
1637+
* A function pointer
1638+
* A delegate
1639+
* An aggregate type instance which defines
1640+
$(DDSUBLINK spec/operatoroverloading, function-call, `opCall`)
16271641

1642+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
16281643
---
16291644
void f(int, int);
16301645

1631-
f(5, 6);
1632-
(&f)(5, 6);
1646+
void g()
1647+
{
1648+
f(5, 6);
1649+
(&f)(5, 6);
1650+
}
16331651
---
1652+
)
16341653

16351654
$(H4 $(LNAME2 argument-parameter-matching, Matching Arguments to Parameters))
16361655

0 commit comments

Comments
 (0)