Local accumulators for cleaner comprehensions

I totally agree!

I think that introducing some kind of DSL that can be packaged as a library (or even added to elixir) is much more productive than creating a new language construct, because at the end of the day, this highly specific feature will be abused countless times by people that are used to mutable state.

Functional languages are good because it has less features, that are easier to reason in a codebase that iteratively gets more complex. Introduction of these concepts will also encourage context leaks, which IMO is the biggest downfall of mutable langauges:

@@magic_value = 20
Enum.map([1, 2 ,3], fn el -> if el == :rand.uniform(3), do: @@magic_value = 21 end)

Even assuming things like above cannot happen, I don’t see the justification of this being a language construct and not just limited scope DSL.

4 Likes