3 ms·
Indeed. The argument of “nested calls are hard to read” is strange, because this looks terrible
by binarymax 4y ago
Indeed. The argument of “nested calls are hard to read” is strange, because this looks terrible
- usrusr 4y agoAnything looks better than nested calls once you have started to get used to the benefits of reading left-to-right. It's one of those pains you don't realize you have unless it suddenly goes away.
- binarymax 4y agoNested calls can be a code smell, sure. But easily fixable: one(two(three())); Becomes let a=three(); let b=two(a); one(b); Clean and easy, no sugar required.
- usrusr 4y agoLots of low-value names required. Those names will inevitably either be badly chosen or have taken far more time to make up than they are worth. That's assuming the code isn't written by that one guy on every team who stubbornly insists on var x = three(); x = two(x); one(x): (having the names certainly is nice to have in the debugger, but I'd rather have those intermediate results be an explicit debugger feature than junk taking up mental bandwidth all over the code, at all times)
- binarymax 4y agoGood point and yours does look better :)
- usrusr 4y agoThe beauty of not using variables is that they don't pollute scope: a promise to the reader that it's perfectly fine to forget about that inermeditate result immediately after seeing it passed into the next step of the pipeline. Otherwise, you never know if it will perhaps show up later for some unexpected purpose. In a left-to-right language, those values that do get a name implicitly stand out
- yamtaddle 4y agoI don't see how moving the actual thing that's returning (and it returns "toward" the left) all the way to the right end of the expression—as far away from the assignment, if any, as possible—improves readability.
- deleted 4y ago[deleted]