さかもとのブログ

つらつらと

closure論争

最近では開発が止まってしまっている?模様の”Closures for the Java Programming Language"を調べていると,closureの定義で論争が起こってい{る?|た?}ことを知った.
まだまだ調べている最中なので何とも言えず,以下のこともどこか間違っているかもしれないが,自分メモとして書く.
closureの定義として,

A closure is a function that captures the bindings of free variables in its lexical context.

Neal Gafter's blog: A Definition of Closures

と書いている人がいる(この方は"Closures for the Java Programming Language"の開発者).
ポール・グレアムもOnLispで

Because Common Lisp is lexically scoped, when we define a function containing
free variables, the system must save copies of the bindings of those variables at
the time the function was defined. Such a combination of a function and a set
of variable bindings is called a closure.

と言っている.
しかし,

As a side-note, the term 'closure' is well-known in functional circles and those dealing with the lambda calculus; in fact, the definition of 'closure' is the same meaning as in English; from dictionary.com :

clo·sure [kloh-zher] Pronunciation Key - Show IPA Pronunciation noun, verb, -sured, -sur·ing.

1. the act of closing; the state of being closed.

In programming languages, a term is 'open' if it has free variables (i.e. those that are not bound to a value) or 'closed' if it has no free variables. Thus, the process of binding values to variables is something that makes a term closed, or 'closure'. It's actually got nothing to do with functions, whether anonymous or otherwise; it's simply about binding variables.

EclipseZone - When is a closure not a closure? ...

まだこの記事をすべて読んだわけではないが(コメントも読まないとこの記事はあんまり意味がない気がするけれどけれど,コメントが多い),意味論的な"closure"と実装上の命名としての"closure"でやりあっている感じ.もちろん意味論と実装は同じであるのが一番よいのだけれど,そんなことを言ったらきりがないような気がする.つまりclosureという表記を見たら,それが何のclosureなのかを気をつけなければならない."Lispの"closureなのか,"Rubyの"closureなのか,"Pythonの"closureなのか...意味論と一致していれば,そんなことは不要だが.
ちなみに,"closure for Java"に対しては,

the idea of Java using the term 'closure' is pretty horrible, especially if it's being used in the wrong way.

EclipseZone - When is a closure not a closure? ...

(boldにしたのは僕です)