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


#56

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


#57

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:


#58

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)

#59

Who said, flattery does not pay :wink:


#60

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:


#61

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:)


#62

also because I liked it too :wink:


#63

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


#64

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: