[erlang-questions] style question - best way to test multiple non-guard conditions sequentially

Siraaj Khandkar <>
Fri Jun 21 06:38:50 CEST 2013


On Jun 20, 2013, at 23:41, Jonathan Leivent <> wrote:

> On 06/20/2013 10:25 PM, Richard A. O'Keefe wrote:
>> ...
>>> The problem is, once you have multiple conditions that are not guards, and that you want to examine sequentially, what simple structure can you come up with in Erlang?
>> 
>> Well, for one thing, it might be an idea to rip the branching structure
>> out of the receive.
> 
> Yeah, sure.  But, I'm forced to do that, instead of deciding to do it if and when it's a good way to modularize the code.  In this particular case, I'd like to see the full conditional all at once, compactly, without obfuscating plumbing, preferably in the receive statement with the other protocol messages.  I think it would just help me think clearly about this key top level of the protocol's decision tree.
> 
> Again, I haven't done a good job justifying the existence of unrestricted sequential conditional statements.

You can fold over an unrestricted list of sequentially ordered closures.

Other than being different from if-then-else, why do you find that approach so unappealing?


> But, considering their ubiquity in virtually all other programming languages, do you really think Erlang's omission of such a construct is a "feature"?
> 
> Although, you might not be trying to argue that.
> 
> Anyway, I appreciate the help with finding an alternative coding scheme - but if it doesn't exhibit the compactness I was hoping for - that I can visualize in an Erlang-like pseudocode - then this isn't really helping here.
> 
> -- Jonathan


More information about the erlang-questions mailing list