I admit to not reading the much-blogged closures proposal all the way through for the simple reason that I use Java version 1.4.2 at work (frankly, I have little to no say in the matter). I'm still waiting to throw out xdoclet for language-level annotations.
Nevertheless, I'm still glad to read Java Closures? Or just functors? Or just confusion? . Antonio does a great jorb defining real closures and functors, and thereby skewering the value of the proposed Java "closures". I especially appreciate this because I am consistently annoyed whenever people refer to a mere anonymous code block as a closure. Back when I used Perl more, I remember understanding code blocks (and references to code blocks) just fine, but having trouble understanding closures. I suppose it's a fine line, since languages with anonymous code blocks probably have lexical context and allow the code access to it, but try to answer the question "can someone create a full closure in Python?" and see how complicated the difference can be.
I didn't know about C++ functors until now. Of course, the term functor also represents a different technique in ML languages...*sob*
Subscribe to:
Post Comments (Atom)
It seems the blog post you referred to completely misread the wikipedia definition for closure. See my reply on that blog.
ReplyDeletewikipedia has a nice page explaining the difference between dynamic and lexical (static) binding, which as I mentioned has a lot to do with closures.
ReplyDeleteActually, Perl variables can swing either way, depending on if the variable is explicitly declared using 'my' or 'local'. The 'my' of lexical scope is used far more often.