"Arie Kusuma Atmaja" <[EMAIL PROTECTED]> writes:
"I ran into them properly for the first time in Smalltalk where they're called Blocks. Lisp uses them heavily." "Essentially a closure is a block of code that can be passed as an argument to a function call." > http://www.martinfowler.com/bliki/Closure.html Ini definisi ngawur yang bagi saya terlalu gatal untuk diacuhkan karena tidak ada mention tentang property paling important yaitu captures of surrounding lexical environment padahal dia pake property ini di beberapa contoh di page itu. Property inilah yang membuat closure unik. Kalau tidak passing block of code seperti dia bilang tidak ada bedanya dengan using callback technique. Closure - a closure is a function that captures the lexical environment in which it was created. GuySteele and GeraldSussman in the 1970s discovered the EquivalenceOfClosuresAndObjects? through their invention of the SchemeLanguage. -- http://c2.com/cgi/wiki?TransactionClosureObject Guy Steele dan Gerald Sussman adalah pencipta Scheme, bahasa pertama yang introduce the concept of closure. Ya, Scheme adalah LISP. Martin Fowler seharusnya sebelum sebut "Lisp uses them heavily" harus research dulu origin dari closure. Bentuk syntaticnya (be it in 'block of code', 'function', 'procedure', 'anon function', 'inner class', etc.) is not important kerena biarpun closure pertama2x dari Scheme, concept itu sudah di-reimplement di banyak bahasa lainnya yang syntaxnya berbeda. Yang penting hanya property of capturing of surrounding lexical environment[1]. Ini dari Scheme language spec, R5RS[2]. Concept yang dijelaskan berikut adalah concept yang di-re-implement di languages lainnya: To each place where an identifier is bound in a program there corresponds a region of the program text within which the binding is visible. The region is determined by the particular binding construct that establishes the binding; if the binding is established by a lambda expression, for example, then its region is the entire lambda expression. Every mention of an identifier refers to the binding of the identifier that established the innermost of the regions containing the use. If there is no binding of the identifier whose region contains the use, then the use refers to the binding for the variable in the top level environment, if any (chapters 4 and 6); if there is no binding for the identifier, it is said to be unbound." -- http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-6.html#%_sec_3.1 YS. Footnotes: [1] "Functionality over form". [2] Notice bahwa di seluruh R5RS tidak ada kata 'closure' sama sekali. Kenapa begitu saya tidak pasti. Yang patut diperhatikan juga adalah spesifikasi tentang concept 'closure' di atas tidak ada di original Scheme paper 'Scheme: an interpreter for extended lambda calculus.' (tahun 1975). Spesifikasi di atas baru terlihat di R3RS (3rd revision of the original paper, tahun 1986). Tapi concept closure sendiri sudah di-implement dari sejak implementasi Scheme pertama (sebelum tahun 1975). Mungkin karena meraka melihat itu hal yang logis dan tidak terhindarkan di lingkungan dimana variables are lexically-scoped, mereka tidak melihat kenapa harus ada namanya.

