2 ms·
> It's called immutable data not immutable identifiers. immutable/mutable data and immutable/mutable identifiers are two different things. One is not called th
by rdtsc 10y ago
> It's called immutable data not immutable identifiers.
immutable/mutable data and immutable/mutable identifiers are two different things. One is not called the other, they are separate things really.
> It's not mutated or changed it points to a totally different memory location
So you said it yourself. It points to a different memory location. So how is x not mutated then? "Mutated" is a synonym for "change", or so I thought apparently.
I don't see how one can look at a variable being reassigned and say "nope, variable didn't change", where it clearly has a new value in the line below.
> Immutable data is what eliminates a large number of potential bugs.
Agreed. Was using Erlang for many years and tried Haskell before. Immutable data is pretty nice most of the time.
> care if someone reuses the name above the point in code you used it.
Wait, is it the opposite of what you were trying to say? Wouldn't you want to care if you are now randomly re-using or changing variables someone else assigned. I thought immutability was a good thing.
> By allowing rebinding you only care about the code below the place your introduced a variable.
Unfortunately in my code base, the code above the place where variables are introduced is just as mission critical as the code after the place. Maybe I am using a strange coding style or paradigm ;-)
- qaq 10y agoI obviously phrased it poorly as not to copy too much text the post by Jose Valim on the topic: http://blog.plataformatec.com.br/2016/01/comparing-elixir-and-erlang-variables/ http://blog.plataformatec.com.br/2016/01/comparing-elixir-an...
- qaq 10y agoa simple illustration of rebinding vs mutation def t() do x=1 f=fn -> x end x=2 f.() end will return 1
- dmix 10y agoThis summarizes my thoughts on "compromise" exactly. It may be a good thing to some people but it was still a compromise to change it for potential benefit in exchange for some potential loss of strict identifier immutability. I prefer the way Erlang does it. But I get why Elixir did what they did as well.