Does Haskell have variables?

前端 未结 5 1071
鱼传尺愫
鱼传尺愫 2020-12-03 01:05

I\'ve frequently heard claims that Haskell doesn\'t have variables; in particular, this answer claims that it doesn\'t, and it was upvoted at least nine times and accepted.<

5条回答
  •  天命终不由人
    2020-12-03 01:37

    According to [Wikipedia](http://en.wikipedia.org/wiki/Variable_(programming)), yes, Haskell has variables:

    In computer programming, a variable is an identifier (usually a letter or word) that is linked to a value stored in the system's memory or an expression that can be evaluated. For instance, a variable might be called "total_count" and contain a number.
    In imperative programming languages, values can generally be accessed or changed at any time. However, in pure functional and logic languages, variables are bound to expressions and keep a single value during their entire lifetime due to the requirements of referential transparency. In imperative languages, the same behavior is exhibited by constants, which are typically contrasted with normal variables.

    Not that all Wikipedia definitions are perfectly trustworthy, of course.

    The page on [mathematical variables](http://en.wikipedia.org/wiki/Variable_(mathematics)) may provide further insight into this.

提交回复
热议问题