4 ms·
I think you are missing some of how Erlang views the world re:if statements. Erlang uses pattern matching rather than assignment, so the statements in the if ar
by tobyhede 17y ago
I think you are missing some of how Erlang views the world re:if statements. Erlang uses pattern matching rather than assignment, so the statements in the if are Guards.
From Pragmatic Programming in Erlang:
At least one of the guards in the if expression must evaluate to true; otherwise, an exception will be raised.
Often the final guard in an if expression is the atom true, which guarantees that the last for m in the expression will be evaluated if all other guards have failed.
- yummyfajitas 17y agoPerhaps my "just wrong" was an overstatement. I guess my real objection is that they should use a different keyword than "if". Like in ocaml: match x with [] -> 0 | _ -> 7 Same semantics, but it doesn't look like a C/Python if statement. They could also use if, but require an else clause (like Haskell). Like it or not, syntax does matter to language adoption.