Re: [Vala] Structure initialisation syntax




On 27/04/11 11:30, David Given wrote:
Fabian Deutsch wrote:
[...]
Copy-n-pasting another way from the the tutorial to initialize a struct
type:

Color c3 = Color() {
     red = 0.5,
     green = 0.5,
     blue = 1.0
};
This is really creating a temporary and then initialising c3 via
assignment, which isn't quite what I was looking for. If you look at the
generated code and compare the above with:

Color c3 = { 0.5, 0.5, 1.0 };

...you can see that the code generated by this syntax avoids the extra
copy. It seems surprising to me that the Type() { initialiser } syntax
supports designated initialisers while the Type t = { initialiser }
syntax doesn't.

File a bug report.

Sam



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]