Get Programming with Haskell 评价人数不足
读书笔记 Lesson 2: Functions and functional programming
tolg

In most programming languages, variables are declared before they’re used. This convention in most programming languages is partially the byproduct of being able to change state. Variable order matters because you can always reassign the value of something after you’ve assigned it. In Haskell, because of referential transparency, this isn’t an issue. There’s also a readability gain with the Haskell approach: if you read the algorithm, the intention is clear right away.

在大多数编程语言里,变量都是在它被使用之前的地方声明。在多数编程语言中这个惯例部分是由于能够改变状态而产生的副产品。变量顺序很重要是因为你总是需要在给一个变量赋值后又再给他赋值。在Haskell中,由于引用透明,这就不是个问题。而且Haskell的这种实现方式还带来了可读性方面的额外的好处:当你去读这个算法,它的意图立刻就非常明显了。

——打破变量使用的惯性思维!

0
《Get Programming with Haskell》的全部笔记 8篇
豆瓣
免费下载 iOS / Android 版客户端