We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Side effect

From Esolang
Jump to navigation Jump to search

A side effect is an effect produced by a function other than returning something. For instance, launched missiles are side effect of this addition function (written in pseudolanguage):

function add(x, y)
{
    launch_missiles();
    return x + y;
}

The same function written without side effects would simply be

function add(x, y)
{
    return x + y;
}

Other side effects would be using input/output or defining or changing variables inside of a function. Some languages, like Haskell, doesn't allow any side effects for functions. It's worth noting that input/output is not necessarily a side effect. Some languages consider a whole program as a function that receives "input" as a parameter it's free to inspect, and "output" is a return value of this function.