Closure Because of What it Can Do or Because it Does

后端 未结 2 1034
迷失自我
迷失自我 2021-02-01 22:23

Ok, this is a bit of a pedantic question but I\'d like to make sure I\'m understanding the definition correctly. Is the closure moniker used to describe anonymous functions that

2条回答
  •  猫巷女王i
    2021-02-01 22:40

    One great definition of a closure is defined here: lua.org

    When a function is written enclosed in another function, it has full access to local variables from the enclosing function; this feature is called lexical scoping. Although that may sound obvious, it is not. Lexical scoping, plus first-class functions, is a powerful concept in a programming language, but few languages support that concept.

提交回复
热议问题