Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.


10.4.1 Side-effects

If evaluating an expression causes the contents of variables to change then that expression is said to have side-effects. An assignment expression is a simple example of an expression with side-effects. Less obvious ones involve function calls with pointers to variables, where the function alters the data being pointed to.

Generally, expressions with side-effects should be avoided unless it is really obvious what is happening. This is because it can be difficult to find problems with your program's code if subtleties are buried in complicated expressions. On the other hand, side-effecting expressions are concise and often very elegant. They are also useful for obfuscating your code (i.e., making it difficult to understand--a form of copy protection!).


Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.