[erlang-questions] Reassigning variables

Vance Shipley vances@REDACTED
Thu Mar 19 17:36:10 CET 2009


On Wed, Mar 18, 2009 at 11:48:34AM +0100, Attila Rajmund Nohl wrote:
}  7 lines (easily fit into one screen) vs 25 lines (probably not much
}  other than this code is shown on the screen) full of no-ops like "_ ->
}  ok" - a really bad idea in my opinion.

OK, here it is on one line:

   try begin case requested_ad_size(Size) of bad -> throw(bad_size); _ -> ok end, case has_ads() of true -> throw(disabled); false -> ok end, case is_filtering() of true -> throw(domain_filtered); false -> ok end end of ok -> yahoo catch Problem -> Problem end.

The point is that if you want to program sequential there is a clear
way to do it.  I use that paradigm quite often in the init/1 functions
of gen_server/gen_fsm.  Your criticism about line counts is quite the
opposite of the readability topic this thread has taken.  You can complain
about Erlang's case statements being too verbose but they are certainly
clear.

-- 

	-Vance



More information about the erlang-questions mailing list