[erlang-questions] [ANN] SeqBind, Sequential Binding Parse Transformation for Erlang (Experimental)

Tim Fletcher mail@REDACTED
Mon Jan 16 17:28:53 CET 2012

> Does it bother you that some of your code looks like this?

No, because it doesn't :)

Same issue mentioned here: http://damienkatz.net/2008/03/what_sucks_abou.html

The problem disappears if you use a functional programming style
instead of an imperative programming style.

The first example could be rewritten as this:

  F = fun (List) -> lists:map(fun (X) -> ... end, List) end
  G = fun (List) -> lists:filter(fun (X) -> ... end, List) end

Admittedly that's not much more readable, but the problem no longer
exists. Realistically you'd probably extract those functions fully,
leaving something like this:


Much easier to read and understand.

Ignoring the obtuse function name in the second example, I can't see
why an "accessor" function should need to return state. So
hypothetically, if the cowboy_http_req module had an API similar to
the proplists module, you'd be able to write something like this

  Q = cowboy_http_req:get_value(<<"q">>, Request)
  Id = cowboy_http_req:get_value(<<"id">>, Request)

Again, the problem no longer exists!


More information about the erlang-questions mailing list