« Prototype Framework is a Javascript Extension, Not Just a Library | Main | Top Ten IT Conversations Shows for September 2008 »

Javascript Thunks

I love how Javascript libraries like JQuery require people to use thunks all over the place:

 $(document).ready(function() {
   $("#orderedlist li:last").hover(function() {
     $(this).addClass("green");
   },function(){
     $(this).removeClass("green");
   });
 });

The functions without parameters are called thunks and their purpose is to delay the evaluation of the code in argument positions, circumventing standard applicative order evaluation. Here’s hoping that future languages—even future versions of Javascript—take this need into account and add real linguistic features for delayed evaluation. Oh wait—Lisp already does and it’s only 50 years old.

Posted by windley on October 3, 2008 1:28 PM

See related posts:

Comments