@@ -1178,7 +1178,7 @@ trait shape {
1178
1178
1179
1179
This defines a trait with two methods.
1180
1180
All values that have [ implementations] ( #implementations ) of this trait in scope can have their ` draw ` and ` bounding_box ` methods called,
1181
- using ` value.bounding_box() ` [ syntax] ( #field -expressions ) .
1181
+ using ` value.bounding_box() ` [ syntax] ( #method-call -expressions ) .
1182
1182
1183
1183
Type parameters can be specified for a trait to make it generic.
1184
1184
These appear after the name, using the same syntax used in [ generic
@@ -1558,13 +1558,27 @@ let base = {x: 1, y: 2, z: 3};
1558
1558
{y: 0, z: 10, .. base};
1559
1559
~~~~
1560
1560
1561
+ ### Method-call expressions
1562
+
1563
+ ~~~~~~~~ {.ebnf .gram}
1564
+ method_call_expr : expr '.' ident paren_expr_list ;
1565
+ ~~~~~~~~
1566
+
1567
+ A _ method call_ consists of an expression followed by a single dot, an identifier, and a parenthesized expression-list.
1568
+ Method calls are resolved to methods on specific traits,
1569
+ either statically dispatching to a method if the exact ` self ` -type of the left-hand-side is known,
1570
+ or dynamically dispatching if the left-hand-side expression is an indirect [ trait type] ( #trait-types ) .
1571
+
1572
+
1561
1573
### Field expressions
1562
1574
1563
1575
~~~~~~~~ {.ebnf .gram}
1564
- field_expr : expr '.' expr
1576
+ field_expr : expr '.' ident
1565
1577
~~~~~~~~
1566
1578
1567
- A dot can be used to access a field in a record.
1579
+ A _ field expression_ consists of an expression followed by a single dot and an identifier,
1580
+ when not immediately followed by a parenthesized expression-list (the latter is a [ method call expression] ( #method-call-expressions ) ).
1581
+ A field expression denotes a field of a [ structure] ( #structure-types ) or [ record] ( #record-types ) .
1568
1582
1569
1583
~~~~~~~~ {.field}
1570
1584
myrecord.myfield;
@@ -1574,17 +1588,9 @@ myrecord.myfield;
1574
1588
A field access on a record is an [ lvalue] ( #lvalues-rvalues-and-temporaries ) referring to the value of that field.
1575
1589
When the field is mutable, it can be [ assigned] ( #assignment-expressions ) to.
1576
1590
1577
- When the type of the expression to the left of the dot is a boxed
1578
- record, it is automatically derferenced to make the field access
1579
- possible.
1580
-
1581
- Field access syntax is overloaded for [ trait method] ( #traits )
1582
- access. When no matching field is found, or the expression to the left
1583
- of the dot is not a (boxed) record, an
1584
- [ implementation] ( #implementations ) that matches this type and the
1585
- given method name is looked up instead, and the result of the
1586
- expression is this method, with its _ self_ argument bound to the
1587
- expression on the left of the dot.
1591
+ When the type of the expression to the left of the dot is a pointer to a record or structure,
1592
+ it is automatically derferenced to make the field access possible.
1593
+
1588
1594
1589
1595
### Vector expressions
1590
1596
0 commit comments