On Sat, 2012-11-03 at 08:39 +0800, Nor Jaidi Tuah wrote:
I think chained assignment should have
Semantic B, for the following reasons:
While I don't particularly like chained assignments in general, I prefer
Semantic A.
* A well designed property should give
the same result for both
* Semantic A is really confusing. e.g.,
var1.myproperty = var2.myproperty = y;
who would have thought that var1.myproperty
is different from var2.myproperty ?!
It's only confusing for non well-behaving properties. The right solution
is to fix the property.
Ok. I
Not surprisingly, the very subtle point raised by
the original poster has been misunderstood.
The OP complained that this
int x = (myclass.myproperty = y);
should behave like this
// Semantic A
myclass.myproperty = y;
int x = myclass.property;
rather than this
// Semantic B
Hello list,
I stumbled on some (for me) unexpected behaviour when setting and
getting a property at the same time, which is not consistend with simple
types like int.
When doing something like
int x = (myclass.myproperty = y);
x will be set to y, and not whatever mycalss.myproperty will be
I think that it is pretty consistent and expected behaviour not only in
Vala but in other languages as well (as long as they allow such things). I
would be worried if it would work other way around. Example:
int x, y;
x = 2;
y = x = 3;
I expect that both y and x will have same value, 3. I would
int x, y = 9;
2012/11/1 Jarosław Ciupiński kotow...@gmail.com
I think that it is pretty consistent and expected behaviour not only in
Vala but in other languages as well (as long as they allow such things). I
would be worried if it would work other way around. Example:
int x, y;
x = 2;
y
I just checked it out with C# and it shows exactly the same behaviour. I
expected it to do
x = 3;
y = x;
rather than
x = 3;
y = 3;
Very interesting and good to know.
I think that it is pretty consistent and expected behaviour not only in
Vala but in other languages as well (as long as