This link has been bookmarked by 10 people . It was first bookmarked on 27 Apr 2006, by netklon.
-
-
So the first crucial point about closures is that they are a
block of code plus the bindings to the environment they came
from. This is the formal thing that sets closures apart from
function pointers and similar techniques.(Java's anonymous inner
classes can access locals - but only if they are final.)The second difference is less of a defined formal difference, but
is just as important, if not more so in practice. Languages that
support closures allow you to define them with very little syntax.
While this might not seem an important point, I believe it's
crucial - it's the key to make it natural to use them frequently.
Look at Lisp, Smalltalk, or Ruby code and you'll see closures all
over the place - much more frequently used than the similar
structures in other languages. The ability to bind to local
variables is part of that, but I think the biggest reason is that
the notation to use them is simple and clear.
-
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.