O'Reilly logo

Functional PHP by Gilles Crettenand

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Immutability

We say a variable is immutable if, once it has been assigned a value, you cannot change its content. After function purity, this is the second most important thing about functional programming.

In some academic languages such as Haskell, you cannot declare variables at all. Everything has to be a function. Since all those functions are also pure, this means you have immutability for free. Some of these languages offers some kind of syntactic sugar that resembles variable declaration to avoid the potential tediousness of always declaring functions.

Most functional languages let you only declare immutable variables or constructs that serves the same purpose. This means you have a way of storing values but it is impossible to change the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required