3 ms·
Well, that's how it works in Erlang... I'm only half-joking - the functions in Erlang are guaranteed to have no side-effects other than sending messages to othe
by klibertp 8y ago
Well, that's how it works in Erlang... I'm only half-joking - the functions in Erlang are guaranteed to have no side-effects other than sending messages to other processes. So, if some computation never sends or receives a message, it is guaranteed to be side-effect free[1]. This is much weaker a guarantee than the function being pure, but in practice, it makes code reuse just a bit easier and writing stealthily mutating functions just a bit harder, which has real advantages.
[1] Not really, though. There's the process dictionary, and there's no way to statically or dynamically mark a function as not using them. The use of it, however, is discouraged to the point that most popular Erlang books only mention it in passing close to the end, or not at all.