Are closures a violation of the functional programming paradigm?

前端 未结 4 1436
伪装坚强ぢ
伪装坚强ぢ 2021-01-31 18:32

Functional programming \"avoids state and mutable data\".

Closures hide state by binding their lexical environment and are thus closed over their free variables

4条回答
  •  别那么骄傲
    2021-01-31 18:57

    My working man's definition of "functional programming" is that if you put the same thing(s) in, you always get the same thing(s) out.

    Closures do not violate this definition in Haskell (try and come up with a closure that does :) ), therefore closures don't violate the FP paradigm.

提交回复
热议问题