Index: dmd/html/d/struct.html =================================================================== --- dmd/html/d/struct.html (revision 83) +++ dmd/html/d/struct.html (working copy) @@ -234,6 +234,14 @@ X + literals + X +   +   +   +   + + RAII   X @@ -455,20 +463,43 @@ S t = s; // sets t.a to 3, S.opCall(s) is not called +

Struct Literals

+ +

Struct literals consist of the name of the struct followed + by a parenthesized argument list:

+ +
struct S { int x; float y; }
+
+int foo(S s) { return s.x; }
+
+foo( S(1, 2) );   // set field x to 1, field y to 2
+
+ +

Struct literals are syntactically like function calls. + If a struct has a member function named opCall, then + struct literals for that struct are not possible. + It is an error if there are more arguments than fields of + the struct. + If there are fewer arguments than fields, the remaining + fields are initialized with their respective default + initializers. + If there are anonymous unions in the struct, only the first + member of the anonymous union can be initialized with a + struct literal, and all subsequent non-overlapping fields are default + initialized. +

+

Struct Properties

-
-.sizeof			Size in bytes of struct
-.alignof		Size boundary struct needs to be aligned on
-.tupleof		Gets type tuple of fields
-
+ + + +
.sizeof Size in bytes of struct
.alignof Size boundary struct needs to be aligned on
.tupleof Gets type tuple of fields

Struct Field Properties

-
-.offsetof		Offset in bytes of field from beginning
-			of struct
-
+ +
.offsetof Offset in bytes of field from beginning of struct
Index: dmd/html/d/function.html =================================================================== --- dmd/html/d/function.html (revision 84) +++ dmd/html/d/function.html (working copy) @@ -13,7 +13,7 @@ -D Programming Language - Functions +Functions - D Programming Language - Digital Mars @@ -1161,6 +1161,10 @@
  • string literals
  • array literals where the members are all items in this list
  • +
  • associative array literals where the members are all items + in this list
  • +
  • struct literals where the members are all items + in this list
  • const variables initialized with a member of this list
  • @@ -1177,7 +1181,7 @@
  • expressions in the function may not:
  • -
  • as a special case, the .dup property - can be executed at compile time +
  • as a special case, the following properties + can be executed at compile time: + + + + +
    .dup
    .length
    .keys
    .values
  • Index: dmd/html/d/expression.html =================================================================== --- dmd/html/d/expression.html (revision 84) +++ dmd/html/d/expression.html (working copy) @@ -121,37 +121,31 @@

    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 , ArgumentList

    NewExpressions 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 @@