The Purpose of Single Assignment

前端 未结 3 1852
误落风尘
误落风尘 2021-01-02 12:21

I\'m currently trying to master Erlang. It\'s the first functional programming language that I look into and I noticed that in Erlang, each assignments that you do is a sing

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-02 13:03

    Having variables keep their values makes it much easier to understand and debug the code. With concurrent processes you get the same kind of problem anyway, so there is enough complication anyway without having just any variable potentially change its value at any time. Think of it as encapsulating side effects by only allowing them when explicit.

提交回复
热议问题