28 ms·
Makes sense, terribly worded by the author, though. Threading generally means, well threads. Throw the word "process" in there and it makes things even less cle
by king_magic 11y ago
Makes sense, terribly worded by the author, though. Threading generally means, well threads. Throw the word "process" in there and it makes things even less clear.
Also, for the record, I totally disagree with the author on this. This:
return (k + 3) * v - foo();
works great, until you need to debug it. Good luck then.
- icebraining 11y agoWhat's the problem? Just put the breakpoint on that line, then check the intermediate values (e.g. with PyDev, you can select parts of the expression to check their results).
- king_magic 11y agoNot every IDE is as helpful or forgiving for that kind of debugging. If you have things broken out, it's much easier to step through the intermediate states of expressions like that, and much easier to tweak when you need to fix something. Having everything together in One Expression To Rule Them All is a code smell, IMHO.
- icebraining 11y agoEven when using C, you can use gdb to evaluate subexpressions at a breakpoint. I don't see why is it a code smell just because some tools are lacking. I do think it's a smell if the expressions has side effects, but that's a different issue.
- king_magic 11y agoI see it as a code smell precisely because some tools are lacking. I don't code for an ideal world where all tools and developers are perfect - personally, I take a practical approach and code for the real world.
- icebraining 11y agoFair enough, but then it's only a smell in languages lacking in those tools. In my real world, I can debug it just fine.
- KingMob 11y agoTrue, but Unnecessary Variables is also a code smell, and a worse one to me, because it increases cognitive load in larger functions. In the toy function given, it doesn't really matter, but in general, I think that people should aim to code for clarity, not ease of debugging.
- nerd_stuff 11y agoIn the author's language, Clojure, it's trivial to print the intermediate value at every stage of a threading macro so you can watch your data as it transforms and pinpoint the problem, ex: (defn debug-it [x] (println x) x) (-> input-value debug-it function1 debug-it function2 debug-it function3 debug-it) Debug-it could also take a custom message at each line if you wanted the output tagged with names/numbers.