If you had to choose one single feature in Elixir that you love the most, what would it be?

Not Elixir, but OTP is the magic that makes Elixir happen. So, for me OTP!

1 Like

I think that bunching all the functions clauses together in one unit is better, it pushes the idea that this is one function and shows more clearly all the bits which comprise the function. Otherwise, in the worst case, you may need to scan the whole module to find the function clauses. I know this is not encouraged but it is legal. Or has it been changed now? However writing macros becomes easier if you can split the function clauses.

And yes, I am influenced by my past with Erlang. :wink:

I entirely agree, that is why I like how OCaml does it, a ā€˜multi-head testā€™ is done via the function keyword:

let someFunc = function
| Blah x -> string_of_int x
| Vwoop 0 -> "invalid"
| Vwoop x when x<0 -> "Lower Vwoop"
| Vwoop x -> "Vwoop"
| ...

Elixir does still require function clauses to be together though, but otherwise they ā€˜lookā€™ like separate function definitions. Of course macroā€™s and super change all that up too. ^.^

For note, super means that a function was defoverrideable theFunction... first, which means that each function internally gets a unique name, and when the module is finally compiled the ā€˜lastā€™ one defined gets the real name, and the ā€˜superā€™ call inside it just delegates to the previously named one. Interesting method to work around the one-definition rule, though again I still like how OCaml does it:

let someFunc x -> x * 2

(* This references the previously defined function *)
let someFunc x -> 2 + someFunc x

(* The `rec` completely hides prior definitions, instead this references itself *)
let rec someFunc x -> if x <= 0 then 0 else someFunc (x-1)
1 Like

Who said, flattery does not pay :wink:

3 Likes

Haha! Well, a little bit of gratitude does not hurt, right? :wink:

And Iā€™m being sincere btw. I really think this forum makes Elixir even better and easy to adoptā€¦ :slight_smile:

3 Likes

Itā€™s the second most liked post in this thread so we canā€™t be doing too badly Robert :lol:

And yes, it does pay :icon_razz: the more you love the forum the more incentivised we are to get you lots of cool prizes and juicy discounts :003: ā€¦and weā€™ve got some awesome stuff for 2018!

(But more on that in our New Year announcement - which Iā€™m running a bit late with sorry - New Years, my birthday, and my mumā€™s birthday all in one week! :101: Hopefully have it all done by next week though :023:)

3 Likes

also because I liked it too :wink:

2 Likes

I could not agree more. The Elixir community is second to none, much like its VM :slight_smile:

4 Likes

I donā€™t know if i answered it before or not.

Pipe operator, no, pattern matching, no, multi clause functions, no, otp, no, ruby like syntax, no, Phoenix, no, Ecto, no, ElixirForum. :slight_smile:

3 Likes