I would like to suggest an alternative function declaration syntax rule :
http://pastebin.mozilla.org/4258633
That will lead to a way shorter function declaration (like Array [...]
and Object {...} does ) :
long story short : <...> will be equivalent to function(...)
Which mean :
var print = <name,age>{ //eq. to var print = function(name,age){...
console.log("my name is " + name + " " + age + "y old.\n");
}
Human = <name,age=0>{
this.age=age;
this.name=age;
this.toString=<>{
return ...
};
}
And so, will work with anonymous function declaration (which was my main goal).
my_list.map(<val>{return val<0?-val:val;});//return absolut-ified array content
I may could be even shorter if expression-only function result were
implicitly returned and it statements treated like "while" and "if"
are (optional braces on single statement) :
var list=[{name:"Johnny",age:36},{name:"Mary",age:35}];
list.map(<e>e.name;);
//equivalent to :
list.map(function(e){return e.name;});
I've implemented and tested this new rule.
* No conflict with any current rules.
* Backward compliant (previous "old-long" declaration still work)
* JS scene could be pleased
Do you think it could be submitted to the next ES draft ?
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss