3 ms·
Imperative code benefits a lot in readability and maintainability if it follows some kind of CQS pattern ( https://en.wikipedia.org/wiki/Command%E2%80%93query_s
by nnq 10y ago
Imperative code benefits a lot in readability and maintainability if it follows some kind of CQS pattern ( https://en.wikipedia.org/wiki/Command%E2%80%93query_separation https://en.wikipedia.org/wiki/Command%E2%80%93query_separati... , http://martinfowler.com/bliki/CommandQuerySeparation.html http://martinfowler.com/bliki/CommandQuerySeparation.html ). Never used Nim but its `discard` keyword seems to nudge people in this direction.
Yeah, looking at it from the perspective an utopical pure functional world this seems as much of an abomination as "out arguments" in C# ...but in real world code things look different :)
- qwertyuiop924 10y agoCQS is neat, but return values on imperative functions are really useful. For one thing, it allows you to compress your API, have an action that can be used solely for the side effect, or for the value of that expression. In addition, you can use it to determine success or failure, and other important information about the function.