concept memory in category functional programming

appears as: memory, memory
Functional Programming in C++

This is an excerpt from Manning's book Functional Programming in C++.

This is great, because you don’t have to think about the program state. But, unfortunately, it also implies that pure functions can’t read from the standard input, write to the standard output, create or delete files, insert rows into a database, and so on. If we wanted to be overly dedicated to immutability, we’d even have to forbid pure functions from changing the processor registers, memory, or anything else on the hardware level.

Figure 5.3 Two concurrent processes want to decrement a value. Each needs to retrieve the value from memory, decrement that value, and store it back into memory. Because the initial value is 2, you expect the result after decrementing it twice to be 0. But if the second process is allowed to read the value from memory before the first process has stored its result back into memory, you may end up with a wrong result.

c05_03.png

These operations are efficient (0(1)), concerning both execution time and memory. You don’t need to copy any data, because both lists share the same data.

Functional Programming in Java: How functional techniques improve your Java programs

This is an excerpt from Manning's book Functional Programming in Java: How functional techniques improve your Java programs.

This is theory. In practice, it’s impossible for a function to have no side effects at all. A function will return a value at some time, and this time may vary. This is a side effect. It might create an out-of-memory error, or a stack-overflow error, and crash the application, which is a somewhat observable side effect. And it will cause writing to memory, registering mutations, thread launching, context switching, and other sorts of things that are indeed effects observable from outside.

  • Reading from files is done in exactly the same way as reading from the console or from memory through the Reader abstraction.