[erlang-questions] Reassigning variables
Taavi Talvik
taavi@REDACTED
Tue Mar 17 22:54:04 CET 2009
On Mar 17, 2009, at 11:19 PM, Matthew Dempsky wrote:
> On Tue, Mar 17, 2009 at 1:38 PM, Justin Sheehy <justin@REDACTED>
> wrote:
>> Single assignment is one of the biggest ways in which Erlang helps
>> reduce bugs. Please don't try to introduce ways around it, as they
>> will make programs worse.
>
> I disagree. There are ways that reassignment can make code easier to
> analyze, but I'm not suggesting people use reassignment in those
> cases.
>
> Similarly, Erlang doesn't support 'return', but our ad server has
> enough business logic where the code would be much simpler if it did.
> We had some code that was effectively:
>
> 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()
Hmm..
if ad size is bad:
throw {skip, bad_size}
if disabled:
throw {skip, disabled}
{serve_ad, choose_ad()}
best regards,
taavi
More information about the erlang-questions
mailing list