[erlang-questions] Nested Case Statements v.s. multiple functions

Michael Truog <>
Tue Sep 26 07:20:35 CEST 2017

On 09/25/2017 10:16 PM, dploop wrote:
> > "Obsessing over a rocket shape doesn't seem as important as the absence of any guard expression usage here. Guards are unfortunately often ignored by Erlang programmers, though they are the one thing in Erlang without side-effects."
> is_integer, is_zero is just a simplified example, and by coincidence, they can use in the guard. But in most situations you can't use guard, for example in game industry when player want to buy equipment, you should check if his coin is sufficient, and then you should check the number of equipment is right and then you  should check if the equipment is valid to exchange and so on. The complex business logic can't be easily solved by guard, and Nested Cases is inevitable.

Complex business logic can be solved by guard expressions and the only potential difference is declaring more variables or more function clauses, depending on how the problem is abstracted. Guards are specifically for logic, so why not use them to express that logic?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170925/b3f8d7c3/attachment.html>

More information about the erlang-questions mailing list