@@ -905,7 +905,7 @@ assert(a[2] == 4);
905
905
---
906
906
)
907
907
908
- $(P $(GLINK IndexExpression ) can also be used with a pointer and has
908
+ $(P $(GLINK IndexOperation ) can also be used with a pointer and has
909
909
the same behaviour as adding an integer, then dereferencing the result.)
910
910
911
911
$(P If the second operand is a pointer, and the first is an integral type,
@@ -1531,8 +1531,8 @@ $(GNAME PostfixExpression):
1531
1531
$(GSELF PostfixExpression) $(D --)
1532
1532
$(GSELF PostfixExpression) $(D $(LPAREN)) $(GLINK NamedArgumentList)$(OPT) $(D $(RPAREN))
1533
1533
$(GLINK2 type, TypeCtors)$(OPT) $(GLINK2 type, BasicType) $(D $(LPAREN)) $(GLINK NamedArgumentList)$(OPT) $(D $(RPAREN))
1534
- $(GLINK IndexExpression )
1535
- $(GLINK SliceExpression )
1534
+ $(GSELF PostfixExpression) $( GLINK IndexOperation )
1535
+ $(GSELF PostfixExpression) $( GLINK SliceOperation )
1536
1536
)
1537
1537
1538
1538
$(TABLE
@@ -1546,8 +1546,8 @@ $(TABLE
1546
1546
)
1547
1547
$(TROW `++`, Increment after use - see $(RELATIVE_LINK2 order-of-evaluation, order of evaluation))
1548
1548
$(TROW `--`, Decrement after use)
1549
- $(TROW *IndexExpression *, Select a single element)
1550
- $(TROW *SliceExpression *, Select a series of elements)
1549
+ $(TROW *IndexOperation *, Select a single element)
1550
+ $(TROW *SliceOperation *, Select a series of elements)
1551
1551
)
1552
1552
1553
1553
$(H3 $(LNAME2 argument-list, Postfix Argument Lists))
@@ -1592,47 +1592,47 @@ S s = S(1, 2);
1592
1592
Uniform construction syntax for built-in scalar types))
1593
1593
1594
1594
1595
- $(H2 $(LNAME2 index_expressions, Index Expressions ))
1595
+ $(H3 $(LEGACY_LNAME2 index_operations, index_expressions, Index Operations ))
1596
1596
1597
1597
$(GRAMMAR
1598
- $(GNAME IndexExpression ):
1599
- $(GLINK PostfixExpression) $( D [) $(GLINK ArgumentList) $(D ])
1598
+ $(GNAME IndexOperation ):
1599
+ $(D [) $(GLINK ArgumentList) $(D ])
1600
1600
)
1601
1601
1602
- $(P $(I PostfixExpression) is evaluated.
1603
- If $(I PostfixExpression) is an expression of static or
1602
+ $(P The base $(I PostfixExpression) is evaluated.
1603
+ The special variable `$` is declared and set to be the number
1604
+ of elements in the base $(I PostfixExpression) (when available).
1605
+ A new declaration scope is created for the evaluation of the
1606
+ $(I ArgumentList) and `$` appears in that scope only.
1607
+ )
1608
+
1609
+ $(P If the $(I PostfixExpression) is an expression of static or
1604
1610
dynamic array type, the result of the indexing is an lvalue
1605
1611
of the *i*th element in the array, where `i` is an integer
1606
1612
evaluated from $(I ArgumentList).
1607
1613
If $(I PostfixExpression) is a pointer `p`, the result is
1608
1614
`*(p + i)` (see $(RELATIVE_LINK2 pointer_arithmetic, Pointer Arithmetic)).
1609
1615
)
1610
1616
1611
- $(P If $(I PostfixExpression) is a $(DDSUBLINK spec/template, variadic-templates, $(I ValueSeq))
1617
+ $(P If the base $(I PostfixExpression) is a $(DDSUBLINK spec/template, variadic-templates, $(I ValueSeq))
1612
1618
then the $(I ArgumentList) must consist of only one argument,
1613
1619
and that must be statically evaluatable to an integral constant.
1614
1620
That integral constant $(I n) then selects the $(I n)th
1615
1621
expression in the $(I ValueSeq), which is the result
1616
- of the $(I IndexExpression ).
1622
+ of the $(I IndexOperation ).
1617
1623
It is an error if $(I n) is out of bounds of the $(I ValueSeq).
1618
1624
)
1619
1625
1620
- $(P The special variable `$` is declared and set to be the number
1621
- of elements in the $(I PostfixExpression) (when available).
1622
- A new declaration scope is created for the evaluation of the
1623
- $(I ArgumentList) and `$` appears in that scope only.
1624
- )
1625
-
1626
1626
$(P The index operator can be $(DDSUBLINK spec/operatoroverloading, array, overloaded).
1627
1627
Using multiple indices in *ArgumentList* is only supported for operator
1628
1628
overloading.)
1629
1629
1630
- $(H2 $(LNAME2 slice_expressions, Slice Expressions ))
1630
+ $(H3 $(LEGACY_LNAME2 slice_operations, slice_expressions, Slice Operations ))
1631
1631
1632
1632
$(GRAMMAR
1633
- $(GNAME SliceExpression ):
1634
- $(GLINK PostfixExpression) $( D [ ])
1635
- $(GLINK PostfixExpression) $( D [) $(GLINK Slice) $(D ,)$(OPT) $(D ])
1633
+ $(GNAME SliceOperation ):
1634
+ $(D [ ])
1635
+ $(D [) $(GLINK Slice) $(D ,)$(OPT) $(D ])
1636
1636
1637
1637
$(GNAME Slice):
1638
1638
$(GLINK AssignExpression)
@@ -1641,21 +1641,28 @@ $(GNAME Slice):
1641
1641
$(GLINK AssignExpression) $(D ..) $(GLINK AssignExpression) $(D ,) $(GSELF Slice)
1642
1642
)
1643
1643
1644
- $(P $(I PostfixExpression) is evaluated.
1645
- If $(I PostfixExpression) is a static or dynamic
1644
+ $(P The base $(I PostfixExpression) is evaluated.
1645
+ The special variable `$` is declared and set to be the number
1646
+ of elements in the $(I PostfixExpression) (when available).
1647
+ A new declaration scope is created for the evaluation of the
1648
+ $(I AssignExpression)`..`$(I AssignExpression) and `$` appears in
1649
+ that scope only.
1650
+ )
1651
+
1652
+ $(P If the base $(I PostfixExpression) is a static or dynamic
1646
1653
array `a`, the result of the slice is a dynamic array
1647
1654
referencing elements `a[i]` to `a[j-1]` inclusive, where `i`
1648
1655
and `j` are integers evaluated from the first and second $(I
1649
1656
AssignExpression) respectively.
1650
1657
)
1651
1658
1652
- $(P If $(I PostfixExpression) is a pointer `p`, the result
1659
+ $(P If the base $(I PostfixExpression) is a pointer `p`, the result
1653
1660
will be a dynamic array referencing elements from `p[i]` to `p[j-1]`
1654
1661
inclusive, where `i` and `j` are integers evaluated from the
1655
1662
first and second $(I AssignExpression) respectively.
1656
1663
)
1657
1664
1658
- $(P If $(I PostfixExpression) is a $(DDSUBLINK spec/template, variadic-templates, $(I ValueSeq)), then
1665
+ $(P If the base $(I PostfixExpression) is a $(DDSUBLINK spec/template, variadic-templates, $(I ValueSeq)), then
1659
1666
the result of the slice is a new $(I ValueSeq) formed
1660
1667
from the upper and lower bounds, which must statically evaluate
1661
1668
to integral constants.
@@ -1669,24 +1676,17 @@ $(GNAME Slice):
1669
1676
The result of the expression is a slice of the elements in $(I PostfixExpression).
1670
1677
)
1671
1678
1672
- $(P The special variable `$` is declared and set to be the number
1673
- of elements in the $(I PostfixExpression) (when available).
1674
- A new declaration scope is created for the evaluation of the
1675
- $(I AssignExpression)`..`$(I AssignExpression) and `$` appears in
1676
- that scope only.
1677
- )
1678
-
1679
- $(P If the $(D [ ]) form is used, the slice is of all the elements in $(I PostfixExpression).
1680
- The expression cannot be a pointer.
1679
+ $(P If the $(D [ ]) form is used, the slice is of all the elements in the base $(I PostfixExpression).
1680
+ The base expression cannot be a pointer.
1681
1681
)
1682
1682
1683
1683
$(P The slice operator can be $(DDSUBLINK spec/operatoroverloading, slice, overloaded).
1684
1684
Using more than one *Slice* is only supported for operator
1685
1685
overloading.)
1686
1686
1687
- $(P A $(I SliceExpression ) is not a modifiable lvalue.)
1687
+ $(P A $(I SliceOperation ) is not a modifiable lvalue.)
1688
1688
1689
- $(H3 $(LNAME2 slice_to_static_array, Slice Conversion to Static Array))
1689
+ $(H4 $(LNAME2 slice_to_static_array, Slice Conversion to Static Array))
1690
1690
1691
1691
$(P If the slice bounds can be known at compile time, the slice expression
1692
1692
may be implicitly convertible to a static array lvalue. For example:)
@@ -1785,7 +1785,7 @@ $(GNAME PrimaryExpression):
1785
1785
$(RELATIVE_LINK2 null, $(D null))
1786
1786
$(LEGACY_LNAME2 true_false)$(DDSUBLINK spec/type, bool, `true`)
1787
1787
$(DDSUBLINK spec/type, bool, `false`)
1788
- $(RELATIVE_LINK2 IndexExpression , `$`)
1788
+ $(RELATIVE_LINK2 IndexOperation , `$`)
1789
1789
$(GLINK_LEX IntegerLiteral)
1790
1790
$(GLINK_LEX FloatLiteral)
1791
1791
$(LEGACY_LNAME2 CharacterLiteral)$(LEGACY_LNAME2 character-literal)$(GLINK_LEX CharacterLiteral)
0 commit comments