What is an Effect?
jessekphillips+D at gmail.com
Sun Jan 2 18:47:35 PST 2011
> | Expressions that have no effect, like (x + x), are illegal in
> | expression statements.
> But what sorts of effects are meant with this?
(x + x) performs a calculation and throws out the result.
x = 42; x = 42;
This is performing an assignment of the same value.
Note that the difference is that the first is context free. x = 42 is doing something even though it would not change behavior of the running program. The first one is just having the CPU run some computation and does not affect the state of the program.
More information about the Digitalmars-d-learn