N
Niklaus
This is one of the posts that i got.
------------------------------
A "side effect" of an operation is something that
*happens*, not something that *is produced*. Examples:
In the expression 2+2, the value 4 *is produced*. Nothing
*happens*.
Thus, 4 is the value of the expression, and it has no side effects.
In the expression g=2.0, the value 2.0 is produced. What *happens*
is that 2.0 is assigned to g. Thus, 2.0 is the value of the
expression,
and its side effect is to assign 2.0 to g.
In the expression (int)g, the value 2 is produced. Nothing happens.
Thus, 2 is the value of the expression (int)g, and it has no side
effects.
In the expression (a=1,++a), the value 2 is produced. What happens
is that first 1 is assigned to a, and then a is incremented; those are
the side effects of the expression.
-----------------------------
This seems to be a good definition in most of the cases.
I argue that in k=(int)2.0 , 2 is produced and the truncation of 2.0
-> 2 is that happens. I am really confused. Can some one give me a
more clear definition of side effects ?
If i apply the same definition to i=j++ where j=3 then i=3 and j=4
are the side effects and value 3,4 are produced. Am i correct ? Can
someone throw more light on how to define side effects without
ambiguity ?
-
Nik
------------------------------
A "side effect" of an operation is something that
*happens*, not something that *is produced*. Examples:
In the expression 2+2, the value 4 *is produced*. Nothing
*happens*.
Thus, 4 is the value of the expression, and it has no side effects.
In the expression g=2.0, the value 2.0 is produced. What *happens*
is that 2.0 is assigned to g. Thus, 2.0 is the value of the
expression,
and its side effect is to assign 2.0 to g.
In the expression (int)g, the value 2 is produced. Nothing happens.
Thus, 2 is the value of the expression (int)g, and it has no side
effects.
In the expression (a=1,++a), the value 2 is produced. What happens
is that first 1 is assigned to a, and then a is incremented; those are
the side effects of the expression.
-----------------------------
This seems to be a good definition in most of the cases.
I argue that in k=(int)2.0 , 2 is produced and the truncation of 2.0
-> 2 is that happens. I am really confused. Can some one give me a
more clear definition of side effects ?
If i apply the same definition to i=j++ where j=3 then i=3 and j=4
are the side effects and value 3,4 are produced. Am i correct ? Can
someone throw more light on how to define side effects without
ambiguity ?
-
Nik