News for hackers. Stuff that matters.
Re:The Development of Erlang (1997) by ratww on Thursday June 03, 2021 @04:55AM (#27378680)
With Pattern Matching
Re:The Development of Erlang (1997) by slver on Thursday June 03, 2021 @07:54AM (#27379906)
Hm that’s if expressions.
Re:The Development of Erlang (1997) by weatherlight on Thursday June 03, 2021 @10:30AM (#27381913)
https://erlang.org/doc/reference_manual/expressions.html#pat...

it's more like the = sign in math mathematics.

2x = 10 we can deduce x = 5

Here's an elixir example where a bunch of "if/else" blocks are refactored to use case statements, and then from case statements to pattern matching.

https://nickjanetakis.com/blog/refactoring-elixir-code-if-co...

Re:The Development of Erlang (1997) by cannabis_sam on Thursday June 03, 2021 @12:28PM (#27383711)
No..?

If-expressions is a specialized version that only works on booleans, pattern matching is a more general concept (that of course can be used to implement if-expressions, but so can pure lambda calculus)

Re:The Development of Erlang (1997) by travisgriggs on Thursday June 03, 2021 @01:38PM (#27384744)
I did not mean to imply that there are no if blocks in Erlang/Elixir. Just that I use them a whole lot less. Probably an order of magnitude less.

And you still have to decide where your code goes at some level. The pattern of having two function variants (one which matches an empty list, and one the head/tail) is a different idiom to looping. So while for loops go away, you still traverse sequences. And more generally, a lot of the if(else) clauses I would normally write, now get solved with pattern matching.

With control flow languages, the where the code goes and what the code does feel very intertwined, whereas with the pattern matching idioms, I find that where it goes, and what it does, are more orthogonally declared.

Re:The Development of Erlang (1997) by saba2008 on Thursday June 03, 2021 @10:47AM (#27382185)
And if statement is just syntax sugar over goto.

After using mostly Erlang for several years, 'if' feels like ugly atavism.

Re:The Development of Erlang (1997) by dnautics on Thursday June 03, 2021 @10:18AM (#27381734)
technically, they are case statements. Even the if is just sugar over case.