>
>
> Thanks for throwing out alternative syntaxes. We should keep beating on
> this anvil, shorter function syntax is well worth it. But we need a non-GLR
> parsing procedure that rejects ambiguous grammars.
So here's my pitch - I've been thinking over a lot of the different
syntaxes that have been passed around, and I've got a combination that
might just work:
// ':' is the clue that this is the start of a short function
coll.map(:x -> x*x) //function(x){ return x*x;}
// even short functions can be named
coll.filter(when: x -> x%2==1) //function when(x){ return x%2==1;}
// multiple parameters, and if the function needs a full function body
coll.forEach(:x, i -> {
if(i%2 === 0){
console.log(x + " is " + even);
}else{
console.log(x + " is " + odd);
}
});
// the names can be an asset in more complicated callback situations
when(promise,
ok: result -> doSomething(result),
error: e -> handleError(e)
);
//if no parameters or name, can drop the ':'
$("#other").click(->$("#target").click());
I think this should be easy to parse, and I feel like using : keeps it from
seeming too foreign.
- Russ
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss