If bar() returned the mutated state, he could just do:
foo(baz(bar())) foo(baz(bar()))This is, of course, a rule of thumb, not a hard law. Some exceptions:
1. I think it's okay (and in fact, idiomatic in C) to mutate state and return some sort of information about what occurred (i.e. a success flag, a number of characters written, etc.).
2. Isolated mutations such as logging sometimes make sense in an otherwise pure function.
return foo().baz().bar();
With flags you start with success/fail, and end up with HRESULT.