" /> Francis Cheng: March 2008 Archives

« February 2008 | Main | April 2008 »

March 31, 2008

New Draft of ECMAScript 4 Edition Grammar Released

Adobe's Jeff Dyer has released a new draft of the ECMAScript 4th Edition normative grammar. The updated draft is available in both PDF and XLS formats. Here are the relevant links:

For those keeping track, here are the changes from the last update (as listed on the normative grammar proposal page on ecmascript.org):
  • Rename ListExpression to CommaExpression;
  • Make CommaExpression a binary expression in the AST;
  • Change ParenExpression to ParenListExpression in SuperExpression;
  • Rename ParenListExpression to ParenExpression;
  • Remove Path qualified PropertyNames;
  • Mark reserved/deferred features with ‘x’;
  • Remove ‘wrap’;
  • Remove ‘like’ as a type;
  • Add ‘like’ as a binary type operator;
  • Remove LetStatement;
  • Remove UnitDefinition;
  • Fold NullableTypeExpression into TypeExpression;
  • Remove OverloadedOperator from QualifiedNameIdentifier;
  • Add distinguishing syntax for tuples and array types in ArrayType;
  • Add SplatExpression to arguments and array literals;
  • Add RestPattern to array patterns;
  • Add to ReservedIdentifiers ‘type’;
  • Add to ContextuallyReservedIdentifiers ‘external’;
  • Removed from ContextuallyReservedIdentifiers ‘decimal’, ‘double’, ‘generic’, ‘int’, ‘Number’, ‘precision’, ‘rounding’, ‘standard’, ‘to’, ‘uint’, ‘unit’;
  • Add LikedPattern to Parameter;
  • Add ‘like’ predicate to ResultType;
  • Remove ParameterKind and use in Parameter

March 30, 2008

Proper Tail Calls Dropped from ECMAScript 4th Edition

Brendan Eich reports that the Proper Tail Calls proposal for ECMAScript 4th Edition has been dropped. Brendan mentioned in a posting to the ES4-Discuss list yesterday that the proposal was dropped at the committee meeting last Friday:

"...(news flash) proper tail calls are out of ES4 as of yesterday's Ecma TC39 meeting, by general (regretful, in Mozilla's case) agreement."

It's not in the meeting notes yet, but I'm sure it will be added before the meeting notes are finalized. I guess the writing was on the wall, because the only three companies that have commented on this feature have all marked this feature as a low priority in the ES4 Progress Tracking Spreadsheet.

March 12, 2008

ECMAScript 4 Edition Progress Spreadsheet

John Resig, Mozilla's JavaScript Evangelist and creator of jQuery, has created a spreadsheet to track the progress of the various implementations of ECMAScript 4th Edition. There are about a half-dozen implementations in development, including the reference implementation that the ECMAScript working group is developing. Here's a brief description of the implementations so that you know what's what when you take a gander at the spreadsheet:

  • ES4 RI: This is the ECMAScript 4th Edition reference implementation that the ES4 working group is developing. It is written in Standard ML '97, except for the library of core classes, which is written in ES4 itself.
  • Tamarin: This began life as the AVM2 (ActionScript Virtual Machine 2), but morphed into Tamarin when the AVM2 was released as open source and handed over to Mozilla for hosting and coordination. Tamarin will serve as the VM for future versions of Flash Player as well as future versions of the FireFox web browser.
  • Spidermonkey: This is a JavaScript engine hosted by Mozilla. It provides scripting support in many applications, some of which are Mozilla FireFox, Yahoo! Widgets, Adobe Acrobat, and Adobe Flash CS3 (allows scripting control of the Flash authoring tool with JSFL).
  • Rhino: This is another Mozilla JavaScript engine, but this one is written entirely in Java and is intended for use in applications rather than in browsers.
  • Futhark: This is a JavaScript engine developed by Opera Software for use in Opera's browser versions 9.5 and 10.0.
  • Mbedthis: Mbedthis specializes in embedded web server solutions and is developing EJScript 3.0, which is based on ES4.
  • JSCore: This is short for JavaScriptCore, which is the JavaScript engine in WebKit.

Yet another set of columns in the spreadsheet indicates the current thinking of several companies that participate in the ES4 working group. It uses color coding to indicate whether a particular feature is high or low priority for a given company. So far, Adobe, Google, Mozilla and Mbedthis have filled out these columns. Apple has indicated that they will have their column filled out by the end of the week. These columns are not binding in any way, but will be used to inform further discussions about the various proposals.

Here's the link to the ES4 progress spreadsheet again, in case you missed it at the top of the post:

March 7, 2008

Proposed ... (splat) operator in ECMAScript 4th Edition allows easy pass-through of rest arguments to super constructor.

Recently, Brendan Eich added a new trac ticket that proposes a new operator, ... (informally called "splat"), for ECMAScript 4th edition. The fate of this ticket is currently unknown, but I really like this proposal because it solves a thorny issue I've had when trying to pass ...rest arguments to a super constructor in ActionScript 3.0. I'll get back to that problem in a minute, but first I want to draw a clear distinction between the proposed ... (splat) operator and the ... (rest) parameter that many of you have probably used in ActionScript 3.0.

In case you don't know, ActionScript 3.0 has a ... (rest) parameter that you can use to specify that a function accepts a variable number of arguments. For example, the Array.push() method uses the rest parameter to signify that it accepts a comma-separated list of arguments:

The ... (splat) operator complements the rest parameter by allowing you to send an array of values as arguments to a function when you don't know ahead of time what the length of that array will be at runtime. In other words, you use the rest parameter when you define what a function will accept as arguments and you use the splat operator when you are actually sending arguments during a function call. Now let's take a quick look at the major use case that the splat operator addresses.

Let's say you have a base class with a constructor that uses a rest parameter. You then create a subclass with a constructor that also uses a rest parameter. How do you pass the arguments from the subclass's constructor to the superclass's constructor? Let's see what happens when we do that:

Note that in the constructor for Base, I trace only the first element of the args array. When I create an instance of Base and pass in the list of numbers 1, 2, 3, the constructor converts the arguments into an array of three elements. However, when I create an instance of Extender with that same list of numbers, they end up bunched together as an array in the first element of the args array in the Base constructor. Unfortunately, in ActionScript 3.0 you cannot use Function.apply() to call the super constructor. There is currently no simple way in ActionScript 3.0 to pass through the arguments to the super constructor and have the arguments treated the same way whether they come from a direct instantiation of Base or through a call to super() from Extender.

The proposed ... (splat) operator solves this problem by allowing simple pass-through of rest arguments using the following new syntax:

Here's a list of relevant links:

March 3, 2008

ECMAScript 4th Edition Vectors Proposal Draft 1

Lars T. Hansen, a computer scientist here at Adobe and the editor of the ECMAScript 4th Edition Specification, has written an initial rough draft of the Vectors proposal. The entire draft is reproduced below from his post on the ES4-Discuss list. I'm reproducing it in its entirety because the discussion list archive converts the file such that you see the raw HTML, which can be a little hard to read. If you have comments, please join the ES4-Discuss list and join in the conversation. Comments on this blog are always welcome, but to get the attention of the ES4 decision makers, you need to join the ES4-discuss list and post your comments there. Here's the link to the draft proposal: