4 ms·
Why write this: f(X) -> X1 = foo(X), X2 = fab(X1), X3 = bar(X2), baz(X3). When you can write this? (I assume this is legal) f(X) -> b
by jey 19y ago
Why write this:
f(X) ->
X1 = foo(X),
X2 = fab(X1),
X3 = bar(X2),
baz(X3).
When you can write this? (I assume this is legal)
f(X) ->
baz(bar(fab(foo(X)))).
- eru 19y agoSometimes shorter lines are easier to read. But in most of the cases you should be right. You can even be more consice by using point-free form: f = baz . bar . fab . foo [Haskell syntax - sorry, I do not know enough about Erlang - but something like this should be possible.]
- mechanical_fish 19y agoI think this is just toy-example syndrome. In my experience the real-world example looks more like this: f(X) -> X1 = foo(X, "Blah blah blah", true, :definitely, :ack), X2 = fab(X1, X, sizeof(X), X-1, bar(X, "martini"), :with_bells_on, :pdq), X3 = bar(X2, "fim tim lim bim whim bim bus stop"), baz(X3). Try chaining that and see how readable it is.
- jey 19y agoTouché.