
I Finally Understand Closures - kirubakaran
http://www.iode.co.uk/blog/pdrummond/i_finally_understand_closures.html
======
aguha
This example demands that you understand some domain-specific needs (of a text
editor), so it's a little annoying.

But, the main idea is right on the mark. The point is that the natural
structure of the code (that uses closures) is completely impossible to achieve
without closures.

Great stuff! I think the author gets it. :-)

------
dominik
A closure is an implementation technique for representing procedures with free
variables. -- SICP @ [http://mitpress.mit.edu/sicp/full-text/book/book-
Z-H-15.html...](http://mitpress.mit.edu/sicp/full-text/book/book-
Z-H-15.html#footnote_Temp_154)

------
ajkirwin
To be honest, I still don't get it. He says, "Such and such will help you
understand closures" and then a few lines of python, then suddenly, "because
start_pos is a closure".

Which, really, still doesn't explain what he means. That and for the love of
god, I hate things such as Clojure. Call me a stick in the mud, but I like
languages in which I don't have to mentally expand 80% of words.

------
sophist
Why are there so many of these "I finally understand [cloures | pointers |
misc CS concept]" posts? I mean these are pretty fundamental concepts that any
first year CS student should be able to grasp pretty quickly.

~~~
ragaskar
I don't think it's so much "I finally understand X", but more of "I finally
have found an application for X".

I think it's interesting to see how other people solve problems.

~~~
swombat
"I've finally found an application for closures" is almost as daft as "I've
finally found an application for variables".

If you haven't found an application for such-and-such basic programming
concept yet, chances are that's because your experience is so limited that you
should probably spend more time coding instead of writing ejaculatory blog
posts.

(not directed at the parent directly, more at the article, which wasted a
minute of my precious life)

------
richcollins
Maybe now he also understands why objects are often preferable. Closures are
liked handicapped objects. Names are resolved when the closures is created,
not when it is called. This is not nearly as flexible as an object, where
names are resolved when the function is called.

~~~
khafra
The venerable master Qc Na was walking with his student, Anton. Hoping to
prompt the master into a discussion, Anton said "Master, I have heard that
objects are a very good thing - is this true?" Qc Na looked pityingly at his
student and replied, "Foolish pupil - objects are merely a poor man's
closures."

Chastised, Anton took his leave from his master and returned to his cell,
intent on studying closures. He carefully read the entire "Lambda: The
Ultimate..." series of papers and its cousins, and implemented a small Scheme
interpreter with a closure-based object system. He learned much, and looked
forward to informing his master of his progress.

On his next walk with Qc Na, Anton attempted to impress his master by saying
"Master, I have diligently studied the matter, and now understand that objects
are truly a poor man's closures." Qc Na responded by hitting Anton with his
stick, saying "When will you learn? Closures are a poor man's object." At that
moment, Anton became enlightened.

~~~
richcollins
I've never seen an implementation of closures with dynamic lookups. Perhaps
you can't point me in the right direction.

