method_missing in JavaScript?
I've posted previously about JavaScript 2 (also known as ECMAScript 4). Since I last discussed this topic, the debate over whether to continue with ES4, which extended JavaScript with type annotations and classes, got significantly less cooperative, and apparently came to a head at the meeting of TC99, the committee responsible for the future of JavaScript.
In summary, it seems that the two groups agreed to focus cooperative effort of ECMAScript 3.1, a modest improvement of the current JavaScript that includes some new features like the ability to mark properties as non-enumerable and freezing objects (which can be used to implement classes).
After that is complete, the two groups have agreed to work on a new version of JavaScript dubbed "Harmony", which will be a more modest evolution of the current JavaScript, minus some of the more ambitious features like namespaces and packages. Other features, like classes, will likely be implemented in terms of new features in ES3.1 like freeze().
Which brings me to the title of my post. Now that it seems as though ES3.1 will be embraced by all the browser vendors moving forward (and will likely be the implemented iteration of JS for at least a little while), I wondered what sorts of features might still make it into ES3.1 before the spec was closed.
Specifically, I've long been interested in trying to get method_missing into JavaScript, and in fact, it is already available in Firefox/Spidermonkey as noSuchMethod. In fact, Johnson makes use of noSuchMethod in its Ruby proxy.
Half-wishing, half-hoping, I threw the idea of codifying noSuchMethod into the discussion on the ES discussion group. As expected, Brendan Eich replied that it was probably too late to add a feature like this into ES3.1 at this time.
But then, to my surprise, Bill Edney and Scott Shattuck, who were responsible for getting noSuchMethod into Spidermonkey, jumped into the fray urging its inclusion into ES3.1. And Justin Meyer, of JavaScriptMVC, posted to their blog also urging its inclusion.
Anyone who's messed with Ruby for more than just a simple Rails app understands the power of method_missing, and getting it into ES3.1, which would mean it would make it into future versions of Firefox, Safari, and IE, would be sweet indeed.