Side effect (computer science)

side effectsside effectside-effectsside-effecteffectsfunctions with side-effectsside effect-free
In computer science, an operation, function or expression is said to have a side effect if it modifies some state variable value(s) outside its local environment, that is to say has an observable effect besides returning a value (the main effect) to the invoker of the operation.wikipedia
121 Related Articles

Subroutine

functionfunctionssubroutines
In computer science, an operation, function or expression is said to have a side effect if it modifies some state variable value(s) outside its local environment, that is to say has an observable effect besides returning a value (the main effect) to the invoker of the operation.
A subroutine call may also have side effects such as modifying data structures in a computer memory, reading from or writing to a peripheral device, creating a file, halting the program or the machine, or even delaying the program's execution for a specified time.

Declarative programming

declarativedeclarative languagedeclarative programming language
By contrast, Declarative programming is commonly used to report on the state of system, without side effects.
Many languages that apply this style attempt to minimize or eliminate side effects by describing what the program must accomplish in terms of the problem domain, rather than describe how to accomplish it as a sequence of the programming language primitives (the how being left up to the language's implementation).

Functional programming

functionalfunctional programming languagefunctional language
In functional programming, side effects are rarely used.
Eliminating side effects, that is, changes in state that do not depend on the function inputs, can make understanding a program easier, which is one of the key motivations for the development of functional programming.

Local variable

localstatic local variablelexical (my) variables
Example side effects include modifying a non-local variable, modifying a static local variable, modifying a mutable argument passed by reference, performing I/O or calling other side-effect functions.
Local variables are fundamental to procedural programming, and more generally modular programming: variables of local scope are used to avoid issues with side-effects that can occur with global variables.

Monad (functional programming)

monadsmonadmonadic
The functional language Haskell expresses side effects such as I/O and other stateful computations using monadic actions.
With a monad, a programmer can turn a complicated sequence of functions into a succinct pipeline that abstracts away auxiliary data management, control flow, or side-effects.

Haskell (programming language)

HaskellHaskell programming languageHackage
The functional language Haskell expresses side effects such as I/O and other stateful computations using monadic actions.
It is a purely functional language, which means that functions generally have no side effects.

Expression (computer science)

expressionexpressionsevaluation environment
In computer science, an operation, function or expression is said to have a side effect if it modifies some state variable value(s) outside its local environment, that is to say has an observable effect besides returning a value (the main effect) to the invoker of the operation.
In many programming languages a function, and hence an expression containing a function, may have side effects.

Scala (programming language)

ScalaScala programming languageScala.js
Functional languages such as Standard ML, Scheme and Scala do not restrict side effects, but it is customary for programmers to avoid them.

Pure function

purepurely functionalpure functions
This requires that the expression is pure, that is to say the expression must be deterministic (always give the same value for the same input) and side-effect free.

Assignment (computer science)

assignmentsingle assignmentassignment operator
One common demonstration of side effect behavior is that of the assignment operator in C++.
An evaluation of expression does not have a side effect if it does not change an observable state of the machine, and produces same values for same input.

Sequence point

sequence points
A sequence point defines any point in a computer program's execution at which it is guaranteed that all side effects of previous evaluations will have been performed, and no side effects from subsequent evaluations have yet been performed.

Input/output

I/Ooutputinterface
Example side effects include modifying a non-local variable, modifying a static local variable, modifying a mutable argument passed by reference, performing I/O or calling other side-effect functions. The functional language Haskell expresses side effects such as I/O and other stateful computations using monadic actions.
This is notable because the I/O functions would introduce side-effects to any programming language, but this allows purely functional programming to be practical.

Idempotence

idempotentidempotencyidempotent element
Note that this is distinct from idempotence under function composition.

Don't-care term

don't caredon't-carecan't happen
Don't care optimization can also be used in the development of highly size-optimized assembly or machine code taking advantage of side effects.

Computer science

computer scientistcomputer sciencescomputer scientists
In computer science, an operation, function or expression is said to have a side effect if it modifies some state variable value(s) outside its local environment, that is to say has an observable effect besides returning a value (the main effect) to the invoker of the operation.

State (computer science)

statestatefulstates
In computer science, an operation, function or expression is said to have a side effect if it modifies some state variable value(s) outside its local environment, that is to say has an observable effect besides returning a value (the main effect) to the invoker of the operation.

Non-local variable

non-local referencenonlocals
Example side effects include modifying a non-local variable, modifying a static local variable, modifying a mutable argument passed by reference, performing I/O or calling other side-effect functions.

Imperative programming

imperativeimperative programming languageimperative language
Imperative programming is commonly used to produce side effects, to update a system's state.

Formal verification

program verificationverificationautomated verification
The lack of side effects makes it easier to do formal verifications of a program.

Standard ML

SMLMoscow MLML
Functional languages such as Standard ML, Scheme and Scala do not restrict side effects, but it is customary for programmers to avoid them.

Scheme (programming language)

SchemeScheme programming languageR6RS
Functional languages such as Standard ML, Scheme and Scala do not restrict side effects, but it is customary for programmers to avoid them.

Assembly language

assemblerassemblyassembly code
Assembly language programmers must be aware of hidden side effects—instructions that modify parts of the processor state which are not mentioned in the instruction's mnemonic.

Status register

Condition codecondition code registercondition codes
A classic example of a hidden side effect is an arithmetic instruction that implicitly modifies condition codes (a hidden side effect) while it explicitly modifies a register (the overt effect).

Processor register

registersregistergeneral purpose register
A classic example of a hidden side effect is an arithmetic instruction that implicitly modifies condition codes (a hidden side effect) while it explicitly modifies a register (the overt effect).