3 ms·
"Pure functions have no impact on any runtime state and that makes them always safe to invoke as a callback." It also makes them UNIVERSALLY USELESS. Think abo
by al2o3cr 12y ago
"Pure functions have no impact on any runtime state and that makes them always safe to invoke as a callback."
It also makes them UNIVERSALLY USELESS. Think about it: a function that definitionally has no side-effects is being called solely for its side-effects.
The article using that to wrap up makes it the equivalent of a complicated category theory proof that successfully proves that the empty set has TONS of amazing properties...
- rian 12y agoPure callbacks aren't universally useless. For instance, the qsort() API can use pure synchronous callbacks effectively: http://linux.die.net/man/3/qsort http://linux.die.net/man/3/qsort The article doesn't advocate always requiring pure callbacks. It's just offered as one possible way to make it easy to reason about the correctness of using an callback API.
- joshvm 12y agoOr presumably this is the same as a 'trivial solution' in physics (normally zero)? Makes the equations work, but generally represents nothing happening.
- groby_b 12y agoOf course, the callback doesn't need to be pure. It just need to be side-effects free with respect to the caller.