Expressions
- C and C++ programmers will find the D expressions very familiar, +C and C++ programmers will find the D expressions very familiar, with a few interesting additions. -
+
- Expressions are used to compute values with a resulting type. +Expressions are used to compute values with a resulting type. These values can then be assigned, tested, or ignored. Expressions can also have side effects. +
-StringLiterals: - StringLiteral - StringLiterals StringLiteral - -ArgumentList: - AssignExpression - AssignExpression , ArgumentList --
Evaluation Order
- Unless otherwise specified, the implementation is free to evaluate +Unless otherwise specified, the implementation is free to evaluate the components of an expression in any order. It is an error to depend on order of evaluation when it is not specified. For example, the following are illegal: +
i = i++; c = a + (a = b); func(++i, ++i);- If the compiler can determine that the result of an expression +
If the compiler can determine that the result of an expression is illegally dependent on the order of evaluation, it can issue an error (but is not required to). The ability to detect these kinds of errors is a quality of implementation issue. +
Expressions
@@ -722,6 +716,10 @@ class ( ArgumentList ) class ( ) class + +ArgumentList: + AssignExpression + AssignExpression , ArgumentListNewExpressions are used to allocate memory on the garbage @@ -988,6 +986,7 @@ CharacterLiteral StringLiterals ArrayLiteral + AssocArrayLiteral FunctionLiteral AssertExpression MixinExpression @@ -1078,6 +1077,13 @@ Otherwise, it resolves to the type with the smallest size it will fit into. +
String Literals
+ +StringLiterals: + StringLiteral + StringLiterals StringLiteral ++
Array Literals
ArrayLiteral: @@ -1104,6 +1110,48 @@ are inserted as arguments in place of the tuple. +Associative Array Literals
+ +AssocArrayLiteral: + [ KeyValuePairs ] + +KeyValuePairs: + KeyValuePair + KeyValuePair , KeyValuePairs + +KeyValuePair: + KeyExpression : ValueExpression + +KeyExpression: + ConditionalExpression + +ValueExpression: + ConditionalExpression ++ +Associative array literals are a comma-separated list of + key:value pairs + between square brackets [ and ]. + The list cannot be empty. + The type of the first key is taken to be the type of + all the keys, and all subsequent keys are implicitly converted + to that type. + The type of the first value is taken to be the type of + all the values, and all subsequent values are implicitly converted + to that type. + An AssocArrayLiteral cannot be used to statically initialize + anything. +
+ +[21u:"he",38:"ho",2:"hi"]; // type is char[2][uint], with keys 21u, 38u and 2u + // and values "he", "ho", and "hi" ++ +If any of the keys or values in the KeyValuePairs are + an ExpressionTuple, then the elements of the ExpressionTuple + are inserted as arguments in place of the tuple. +
+Function Literals
FunctionLiteral Index: dmd/html/d/changelog.html =================================================================== --- dmd/html/d/changelog.html (revision 85) +++ dmd/html/d/changelog.html (working copy) @@ -210,6 +210,8 @@
-
+
- What's new for D 1.014 +
- What's new for D 1.013
- What's new for D 1.012 @@ -248,6 +250,37 @@
- Added associative array literals +
- Added struct literals +
- Array element assignments can now be done in CTFE +
- Bugzilla 1000: writefln fails on nested arrays +
- Bugzilla 1143: Assertion failure: '0' on line 850 in 'template.c' - On specialization of IFTI template parameters. +
- Bugzilla 1144: template mixin causes DMD crash +
- Bugzilla 1146: mixin + assert() crashes compiler +
- Bugzilla 1153: dmd assertion failure +
- Bugzilla 1159: Various mixins cause "CompileExp::semantic" message, some crash DMD +
- Bugzilla 1174: Program hangs creating an array of enums with nonzero initializer +
- Bugzilla 1177: no longer works inside CTFE functions. +
- Bugzilla 1180: the GC failes to handle large allocation requests propperly +
- Bugzilla 1189: Reverse the titles on web pages +
+
+ What's New for + D 1.014 +
+ + +Apr 20, 2007 + +New/Changed Features
+ +Bugs Fixed
+ ++