我认为,我发现关闭的定义含糊不清。 具体来说,似乎允许外部范围成为全球范围。
For instance from the wikipedia article at: http://en.wikipedia.org/wiki/Closure_(computer_science)
“封闭(也具有灵活性的封闭、功能关闭或功能价值)是一种功能,也是该功能非当地变量的参照环境。
具体来说,非当地可包括全球变量。 甚至 指出“这一术语可以指全球变量”。 它进而确定问题,指出全球并非通常的含义。
Nevertheless, I think we might need to be more stringent in the definition of closures to specifically exclude global variables as the non-local variables. Or is there some case where globals are valid in this context?
EDIT:
Based on comments received and additional thought, to me it seems that there is one specific circumstance where the current definition of closure, ignoring globals, falls short. And that is when the code/function that might otherwise qualify as a closure, can only reference non-local variables that are also global variables