A side effect is an observable state change accompanying evaluation beyond the returned value. Writing a file, changing a shared variable or modifying an argument object are examples. A function can return the same numeric answer on repeated calls while producing different observable behaviour by appending to a log each time. Replacing the second call with a cached result then changes the program's behaviour. A pure function avoids such observable effects and returns its result from its inputs alone; languages can still provide explicit mechanisms for sequencing necessary effects.
// Target: computer-science.bigb
Articles by others on the same topic
There are currently no matching articles.