[erlang-questions] Reassigning variables

Johnny Billquist bqt@REDACTED
Tue Mar 17 23:42:21 CET 2009

Tony Arcieri wrote:
> On Tue, Mar 17, 2009 at 3:53 PM, Johnny Billquist <bqt@REDACTED 
> <mailto:bqt@REDACTED>> wrote:
>     Huh? What's wrong with coding that in Erlang as:
>     foo() ->
>       if
>         requested ad size is bad ->
>           {skip, bad_size};
>         the game has ads disabled ->
>           {skip, disabled};
>         the game is filtering a domain ->
>           {skip, domain_filtered};
>         _ ->
>           choose_ad()
>       end.
>            Johnny
> It sounds from his description like the pseudocoded conditions are a bit 
> more involved than just a guard.

Well, you can achieve the same with nexted case statements, which 
removes the restrictions frmo guards, if that is needed. The value of a 
function is always the value of the last "statement", and that can be 
different things without problems. And executing a specific branch of 
code is not something magic.

The multiple return stateents seems to me like a non-issue. There are 
not problems that I've ever seen that have come close to that. And using 
throw/catch seems to me like just some extra distance to go to for this 
simple problem.

But maybe I'm missing something else/more here?


Johnny Billquist                  || "I'm on a bus
                                   ||  on a psychedelic trip
email: bqt@REDACTED             ||  Reading murder books
pdp is alive!                     ||  tryin' to stay hip" - B. Idol

More information about the erlang-questions mailing list