Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

12
  • 40
    While I agree that F(G1(H1(b1), H2(b2)), G2(c1)) is hard to read, this has nothing to do with being crammed too dense. (Not sure if you meant to say that, but it could be interpreted this way.) Nesting three or four functions in a single line can be perfectly readable, in particular if some of the functions are simple infix operators. It is the nondescriptive names that are the problem here, but that problem is even worse in the multi-line version, where yet more nondescriptive names are introduced. Adding only boilerplate almost never aids readability. Commented Feb 22, 2018 at 14:43
  • 26
    @leftaroundabout: To me, the difficulty is that it's not obvious whether G1 takes 3 parameters or only 2 and G2 is another parameter to F. I have to squint and count the parentheses. Commented Feb 22, 2018 at 15:26
  • 4
    @MatthieuM. this can be an issue, though if the functions are well-known it is often obvious which takes how many arguments. Specifically, as I said, for infix functions it's immediately clear that they take two arguments. (Also, the parenthesized-tuples syntax most languages use exacerbates this problem; in a language that prefers Currying it's automatically clearer: F (G1 (H1 b1) (H2 b2)) (G2 c1).) Commented Feb 22, 2018 at 15:39
  • 5
    Personally I prefer the more compact form, as long as there's styling around it like in my prior comment, because it guarantees less state to mentally keep track of - result_h1 cannot be reused if it doesn't exist, and the plumbing between the 4 variables is obvious. Commented Feb 22, 2018 at 16:09
  • 9
    I have found that code that's easy to debug generally is code that doesn't need debugging. Commented Feb 22, 2018 at 20:57