|
|
|
|
|
by copsarebastards
3894 days ago
|
|
I think a better design would be to separate mutators from pure functions. If a procedure mutates state, it should have a void return type, and if a procedure returns a value it should be a pure function that doesn't mutate state. 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. |
|