3 ms·
Names are great places to put documentation. Documentation in comments isn't as likely to stay up-to-date. If your names are merely for binding (e.g: f(x) = ..
by Peaker 16y ago
Names are great places to put documentation. Documentation in comments isn't as likely to stay up-to-date.
If your names are merely for binding (e.g: f(x) = .. x ..) and don't contribute much, then getting rid of them can be helpful. In Haskell, you can use "points-free" style to get rid of names like that. For example, you can replace:
f x = 1 + 2 * x
With:
f = (1+) . (2*)
- joe_the_user 16y agoThat's a nice simple explanation of the points-free style, thanks! But still, I don't feel like this approach would become useful unless/until you reached the point that it could condense a two-line formula into one line (ei, five or six applications further). I strong suspect that in that case you'd have the kind of formula you only grasp at a glance after you'd working with it intensively for a while. And this gets into the realm of "write only code" - code too compressed for anyone but it's original author to approach.