in reply to Re^34: Side-effects are bad form [was: Why is the execution order...]
in thread Why is the execution order of subexpressions undefined?
Any form of IO is a side-effect, regardless of where you do it.
In an imperative language, 'functions' (procdures that return values if you prefer) are the major mechanism of code structuring. When I do IO to a database, I call a function (or method (same difference). When I read or write to a file, I call a function. When I read or write to a socket udp/tcp/http/ftp/telnet/et al, it is all done with functions and all of those functions that do IO have side-effects. f(a) + g(b) * h(c)
f(a) retrieves the range from the radar.
g(b) retrieves a correction factor from the wind speed indicator.
h(c) gets a scalar from a lookup table in memory. keyed upon the type of shell (HE, tracer, AP) that will load next from the belt.
The final result is used to adjust the elevation of the barrel in real time.
How do you avoid the side effects?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^36: Side-effects are bad form [was: Why is the execution order...]
by Anonymous Monk on Apr 19, 2005 at 15:51 UTC | |
|
Re^36: Side-effects are bad form [was: Why is the execution order...]
by Anonymous Monk on Apr 19, 2005 at 16:04 UTC | |
|