<s>
In	O
computer	B-General_Concept
programming	I-General_Concept
,	O
a	O
pure	B-Application
function	I-Application
is	O
a	O
function	O
that	O
has	O
the	O
following	O
properties	O
:	O
</s>
<s>
the	O
function	O
has	O
no	O
side	O
effects	O
(	O
no	O
mutation	O
of	O
local	O
static	B-General_Concept
variables	I-General_Concept
,	O
non-local	O
variables	O
,	O
mutable	O
reference	O
arguments	O
or	O
input/output	B-General_Concept
streams	O
)	O
.	O
</s>
<s>
Thus	O
a	O
pure	B-Application
function	I-Application
is	O
a	O
computational	O
analogue	O
of	O
a	O
mathematical	O
function	O
.	O
</s>
<s>
The	O
following	O
examples	O
of	O
C++	B-Language
functions	O
are	O
pure	O
:	O
</s>
<s>
The	O
following	O
C++	B-Language
functions	O
are	O
impure	O
as	O
they	O
lack	O
the	O
above	O
property	O
1	O
:	O
</s>
<s>
The	O
following	O
C++	B-Language
functions	O
are	O
impure	O
as	O
they	O
lack	O
the	O
above	O
property	O
2	O
:	O
</s>
<s>
The	O
following	O
C++	B-Language
functions	O
are	O
impure	O
as	O
they	O
lack	O
both	O
the	O
above	O
properties	O
1	O
and	O
2	O
:	O
</s>
<s>
I/O	B-General_Concept
is	O
inherently	O
impure	O
:	O
input	O
operations	O
undermine	O
referential	O
transparency	O
,	O
and	O
output	O
operations	O
create	O
side	O
effects	O
.	O
</s>
<s>
Nevertheless	O
,	O
there	O
is	O
a	O
sense	O
in	O
which	O
a	O
function	O
can	O
perform	O
input	O
or	O
output	O
and	O
still	O
be	O
pure	O
,	O
if	O
the	O
sequence	O
of	O
operations	O
on	O
the	O
relevant	O
I/O	B-General_Concept
devices	I-General_Concept
is	O
modeled	O
explicitly	O
as	O
both	O
an	O
argument	O
and	O
a	O
result	O
,	O
and	O
I/O	B-General_Concept
operations	I-General_Concept
are	O
taken	O
to	O
fail	O
when	O
the	O
input	O
sequence	O
does	O
not	O
describe	O
the	O
operations	O
actually	O
taken	O
since	O
the	O
program	O
began	O
execution	O
.	O
</s>
<s>
The	O
second	O
point	O
ensures	O
that	O
the	O
only	O
sequence	O
usable	O
as	O
an	O
argument	O
must	O
change	O
with	O
each	O
I/O	B-General_Concept
action	O
;	O
the	O
first	O
allows	O
different	O
calls	O
to	O
an	O
I/O	B-General_Concept
-performing	O
function	O
to	O
return	O
different	O
results	O
on	O
account	O
of	O
the	O
sequence	O
arguments	O
having	O
changed	O
.	O
</s>
<s>
The	O
I/O	B-General_Concept
monad	O
is	O
a	O
programming	O
idiom	O
typically	O
used	O
to	O
perform	O
I/O	B-General_Concept
in	O
pure	O
functional	O
languages	O
.	O
</s>
<s>
A	O
C++	B-Language
example	O
is	O
the	O
length	O
method	O
,	O
returning	O
the	O
size	O
of	O
a	O
string	O
,	O
which	O
depends	O
on	O
the	O
memory	O
contents	O
where	O
the	O
string	O
points	O
to	O
,	O
therefore	O
lacking	O
the	O
above	O
property	O
1	O
.	O
</s>
<s>
In	O
Fortran	B-Application
and	O
D	O
,	O
the	O
pure	O
keyword	O
can	O
be	O
used	O
to	O
declare	O
a	O
function	O
to	O
be	O
just	O
side-effect	O
free	O
(	O
i.e.	O
</s>
<s>
In	O
the	O
GCC	B-Application
,	O
the	O
pure	O
attribute	O
specifies	O
property	O
2	O
,	O
while	O
the	O
const	O
attribute	O
specifies	O
a	O
truly	O
pure	B-Application
function	I-Application
with	O
both	O
properties	O
.	O
</s>
<s>
Examples	O
include	O
constexpr	O
of	O
C++	B-Language
(	O
both	O
properties	O
)	O
.	O
</s>
<s>
Since	O
pure	B-Application
functions	I-Application
have	O
identical	O
return	B-Language
values	I-Language
for	O
identical	O
arguments	O
,	O
they	O
are	O
well	O
suited	O
to	O
unit	O
testing	O
.	O
</s>
