2 constructing arrays of objects
3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 Initialization lists for arrays of objects with constructors,
6 have an alternative meaning in lwc and they're used to call the
7 constructor for each element of the array.
9 For an object 'A' with constructor, the declaration
11 A x [] = { E1, E2, E3 }
17 if E1 is not enclosed in parentheses, or
25 if E1 starts with a '.'
26 Same for x[1] and x[2].
28 If the size of the array is specified, then lwc will call
29 the ctor with no arguments for the remaining elements. For example in:
41 The feature will be avoided if lwc detects nested braces in the initializer.
43 An example with all the possible cases:
48 A (int x) { i = j = x; }
49 A (int x, int y) { i = x, j = y; }
50 void altctor (int x) { j = -(i = x); }
58 (1,2), // a[2].ctor (1, 2)
60 .altctor (3) // a[4].altctor (3)
61 // a[5].ctor(), a[6].ctor()
64 // Not done. Nested braces. Remains as is
65 A b [] = { { 1, 2 }, { 3, 4 } };
68 The feature, normally should work for 'new' and 'localloc'. And it is.
69 The syntax is that the initializer must follow the array brackets. Example:
73 A *p1 = new A [] { 1, 2, 3, altctor (123) };
74 A *p2 = localloc A [12] { };
75 A *p3 = new A [5] { (1, 2), (3, 4) };
79 *!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!
80 KNOWN BUG: They are not destructed though !!!!
81 *!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!