@@ -988,69 +988,6 @@ $(GNAME ComplementExpression):
988
988
prior to the complement operation.
989
989
)
990
990
991
- $(H3 $(LNAME2 new_expressions, New Expressions))
992
-
993
- $(GRAMMAR
994
- $(GNAME NewExpression):
995
- $(D new) $(GLINK2 type, Type)
996
- $(D new) $(GLINK2 type, Type) $(D [) $(GLINK AssignExpression) $(D ])
997
- $(D new) $(GLINK2 type, Type) $(D $(LPAREN)) $(GLINK ArgumentList)$(OPT) $(D $(RPAREN))
998
- $(GLINK2 class, NewAnonClassExpression)
999
-
1000
- $(GNAME ArgumentList):
1001
- $(GLINK AssignExpression)
1002
- $(GLINK AssignExpression) $(D ,)
1003
- $(GLINK AssignExpression) $(D ,) $(GSELF ArgumentList)
1004
- )
1005
-
1006
- $(P $(I NewExpression)s are used to allocate memory on the garbage
1007
- collected heap.
1008
- )
1009
-
1010
- $(P If a $(I NewExpression) is used as an initializer for
1011
- a function local variable with $(D scope) storage class,
1012
- then the instance is allocated on the stack.
1013
- )
1014
-
1015
- $(H3 $(LNAME2 new_multidimensional, Multidimensional Arrays))
1016
-
1017
- $(P To allocate multidimensional arrays, the declaration reads
1018
- in the same order as the prefix array declaration order.)
1019
-
1020
- -------------
1021
- char[][] foo; // dynamic array of strings
1022
- ...
1023
- foo = new char[][30]; // allocate array of 30 strings
1024
- -------------
1025
-
1026
- $(P The above allocation can also be written as:)
1027
-
1028
- -------------
1029
- foo = new char[][](30); // allocate array of 30 strings
1030
- -------------
1031
-
1032
- $(P To allocate the nested arrays, multiple arguments can be used:)
1033
-
1034
- ---------------
1035
- int[][][] bar;
1036
- ...
1037
- bar = new int[][][](5, 20, 30);
1038
- ---------------
1039
-
1040
- The code above is equivalent to:
1041
-
1042
- ----------
1043
- bar = new int[][][5];
1044
- foreach (ref a; bar)
1045
- {
1046
- a = new int[][20];
1047
- foreach (ref b; a)
1048
- {
1049
- b = new int[30];
1050
- }
1051
- }
1052
- -----------
1053
-
1054
991
$(H3 $(LNAME2 delete_expressions, Delete Expressions))
1055
992
1056
993
$(GRAMMAR
@@ -1773,7 +1710,7 @@ $(GNAME ArrayMemberInitialization):
1773
1710
---
1774
1711
)
1775
1712
1776
- $(H3 $(LNAME2 cast_array_literal, Casting))
1713
+ $(H4 $(LNAME2 cast_array_literal, Casting))
1777
1714
1778
1715
$(P When array literals are cast to another array type, each
1779
1716
element of the array is cast to the new element type.
@@ -2272,6 +2209,73 @@ $(GNAME ImportExpression):
2272
2209
}
2273
2210
---
2274
2211
2212
+ $(H3 $(LNAME2 new_expressions, New Expressions))
2213
+
2214
+ $(GRAMMAR
2215
+ $(GNAME NewExpression):
2216
+ $(D new) $(GLINK2 type, Type)
2217
+ $(D new) $(GLINK2 type, Type) $(D [) $(GLINK AssignExpression) $(D ])
2218
+ $(D new) $(GLINK2 type, Type) $(D $(LPAREN)) $(GLINK ArgumentList)$(OPT) $(D $(RPAREN))
2219
+ $(GLINK2 class, NewAnonClassExpression)
2220
+
2221
+ $(GNAME ArgumentList):
2222
+ $(GLINK AssignExpression)
2223
+ $(GLINK AssignExpression) $(D ,)
2224
+ $(GLINK AssignExpression) $(D ,) $(GSELF ArgumentList)
2225
+ )
2226
+
2227
+ $(P $(I NewExpression)s are used to allocate memory on the
2228
+ $(DDLINK spec/garbage, Garbage Collection, garbage
2229
+ collected) heap.
2230
+ )
2231
+
2232
+ $(P If a $(I NewExpression) is used as an initializer for
2233
+ a function local variable with $(DDSUBLINK spec/attribute, scope, `scope`) storage class,
2234
+ then the instance is allocated on the stack.
2235
+ )
2236
+
2237
+ $(P `new` can also be used to allocate a
2238
+ $(DDSUBLINK spec/class, nested-explicit, nested class).)
2239
+
2240
+ $(H4 $(LNAME2 new_multidimensional, Multidimensional Arrays))
2241
+
2242
+ $(P To allocate multidimensional arrays, the declaration reads
2243
+ in the same order as the prefix array declaration order.)
2244
+
2245
+ -------------
2246
+ char[][] foo; // dynamic array of strings
2247
+ ...
2248
+ foo = new char[][30]; // allocate array of 30 strings
2249
+ -------------
2250
+
2251
+ $(P The above allocation can also be written as:)
2252
+
2253
+ -------------
2254
+ foo = new char[][](30); // allocate array of 30 strings
2255
+ -------------
2256
+
2257
+ $(P To allocate the nested arrays, multiple arguments can be used:)
2258
+
2259
+ ---------------
2260
+ int[][][] bar;
2261
+ ...
2262
+ bar = new int[][][](5, 20, 30);
2263
+ ---------------
2264
+
2265
+ The code above is equivalent to:
2266
+
2267
+ ----------
2268
+ bar = new int[][][5];
2269
+ foreach (ref a; bar)
2270
+ {
2271
+ a = new int[][20];
2272
+ foreach (ref b; a)
2273
+ {
2274
+ b = new int[30];
2275
+ }
2276
+ }
2277
+ -----------
2278
+
2275
2279
$(H3 $(LNAME2 typeid_expressions, Typeid Expressions))
2276
2280
2277
2281
$(GRAMMAR
@@ -2710,7 +2714,7 @@ $(SPEC_RUNNABLE_EXAMPLE_COMPILE
2710
2714
)
2711
2715
2712
2716
2713
- $(H2 $(LNAME2 specialkeywords, Special Keywords))
2717
+ $(H3 $(LNAME2 specialkeywords, Special Keywords))
2714
2718
2715
2719
$(GRAMMAR
2716
2720
$(GNAME SpecialKeyword):
0 commit comments