That’s really interesting. I’m too new to math behind functional programming, so Y combinator isn’t for me now, but I initially thought about slightly different approach: new keyword $
, which would always refer to the current function. This would not only allow named anonymous function, but shorten a bit plain functions.
For example:
def len(x) when is_list(x), do: _len(x, 0)
defp _len([], acc), do: acc
defp _len([_ | t], acc) , do: $(t, acc+1)
I’m typically not fond of introducing new keywords for every small feature, but this could be really helpful in writing clean and concise code.