I have one semi-large code base where I validate the locking semantics
by adding assert(!lock.try_acquire)'s. That's clearly a side effect,
but also clearly should never have one if the code is correct.
On 2/3/14, 10:20 AM, bearophile wrote:
Daniel Murphy:
Do you really want to force all codebases to 'pure'ify all their
functions?
What percentage of your functions are transitively called in your
asserts? In my code it's a small percentage.
A function call in an assert might be a red flag, but it certainly
isn't a bug.
I agree. I am suggesting to disallow just impure functions in asserts.
We have an acceptably good type system, but are we afraid of using it?
Bye,
bearophile