I don't understand the wikipedia article on Side Effects:
In computer science, a function or expression is said to have a side effect if, in addition to returning a value, it also 1.) Modifies some state or 2.) Has an observable interaction with calling functions or the outside world.
I know an example of the first thing that causes a function or expression to have side effects - modifying a state
Function and Expression modifying a state
:
1.)
foo(int X)
{
return x = x % x;
}
a = a + 1;
What does 2.) - Has an observable interaction with calling functions or the outside world," mean? - Please give an example.
The article continues on to say, "For example, a function might modify a global or static variable,
modify one of its arguments, raise an exception, write data to a display or file, read data, or call other side-effecting functions...." Are all these examples, examples of 1.) - Modifiying some state , or are they also part of 2.) - Has an observable interaction with calling functions or the outside world?