[erlang-questions] Reassigning variables

Attila Rajmund Nohl attila.r.nohl@REDACTED
Wed Mar 18 11:48:34 CET 2009


2009/3/17, Vance Shipley <vances@REDACTED>:
> On Tue, Mar 17, 2009 at 02:19:48PM -0700, Matthew Dempsky wrote:
> }  Similarly, Erlang doesn't support 'return'
>
> Doesn't it?
>
> }      if requested ad size is bad:
> }          return {skip, bad_size}
> }      if the game has ads disabled:
> }          return {skip, disabled}
> }      if the game is filtering a domain:
> }          return {skip, domain_filtered}
> }      return choose_ad()
>
> 	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

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.



More information about the erlang-questions mailing list