Expanded function syntax

Brendan Eich brendan at mozilla.org
Fri Feb 1 12:01:23 PST 2008

On Jan 31, 2008, at 5:13 PM, Mark Filipak wrote:

> Hello,
> (Sorry. What I meant to write is below.)
> May I make a pitch for an expanded function syntax? This example will
> say it all (I hope).
> What I have to write now:
>  getFirstChildOfElementWithTagName(Papa, 'baby');
> What I'd like to be able to write:
>  getFirstChildOfElement(Papa)withTagName('baby');

If you put a . after the first ) then you can write such a chained  
expression today. It costs one more function object and one more .  
character, but if it's important to you for clarity, those costs may  
be worth paying.

>  function getFirstChildOfElement(Papa)withTagName(babyTagName) {
>    alert(arguments[0].tagName);   // Show Papa's tag name
>    alert(arguments[1]);   // Show desired baby's tag name
>  }
> I don't think such an expanded capability would have any backward
> compatibility issues. It would make function calls more readable and
> easier to remember.

It's unusual syntax; some including me would argue that it's less  
readable. It's too late for a non-trivial sugaring such as this  
without stronger motivation, in my opinion. Others should weight in  
if they feel differently.


More information about the Es4-discuss mailing list