|
|
|
|
|
by JadeNB
3560 days ago
|
|
> I've heard a number of definitions, but the best ones are far more technical than you'd see in casual conversation To be sure, but there's a big difference between casual definitions being subtly wrong and: > I mean that it's not even so well defined mathematically. Most mathematical definitions, at least the interesting ones, aren't really suitable for casual conversation! |
|
The best casual definition I know of is "a pure function, f, is one such that all variation in the function's result arises from variation in its input and that all information from the function's call is contained in its result: throwing the result away is equivalent to having never called the function"
A bit of a mouthful, but it's intuitive and arises from a formal definition that works out pretty nicely. Otoh, it's complex enough that it's rarely used in its complete form. Finally, it's still subtle enough that it can lead to questions about what side effects are exactly (non-termination is an immediate example).
Anyway, I just want to continue to suggest that understanding pure functions, really, is a more difficult task than people make it out to be.