Wednesday, August 30, 2006

the Java closures that aren't

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*

2 comments:

  1. It seems the blog post you referred to completely misread the wikipedia definition for closure. See my reply on that blog.

    ReplyDelete
  2. wikipedia has a nice page explaining the difference between dynamic and lexical (static) binding, which as I mentioned has a lot to do with closures.

    Actually, 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.

    ReplyDelete

Note: Only a member of this blog may post a comment.