arrow syntax unnecessary and the idea that "function" is too long
Jorge
jorge at jorgechamorro.com
Sat May 7 01:37:20 PDT 2011
On 07/05/2011, at 02:04, Peter Michaux wrote:
> (...)
>
> If the arrow syntax is only syntactic sugar for the existing function
> forms then I don't see how it achieves any of the goals he outlined.
> The only possible category is "be a better language" but the arrow
> syntax won't make JavaScript a better language for complex
> applications or libraries in comparison to any other kind of
> JavaScript code. I would argue that the arrow syntax will make
> JavaScript a worse language anyway as there are already perfectly good
> forms using the "function" keyword now. We don't need new syntax and
> we don't need multiple ways to do the same thing just for the sake 6
> characters. Please keep JavaScript simple.
>
> (...)
This above is ~ how I feel about it too.
But if I wanted a shorter syntax, I would no doubt choose ruby blocks' syntax, it's even shorter yet and it's familiar already to millions of programmers.
On 07/05/2011, at 03:22, David Bruant wrote:
>
> I'm attracted to the idea of a shorter function syntax not only because
> it reduces the number of characters of the "function" keyword, but also
> because it gets rid of the "return" keyword (and corresponding semicolon).
(return does not need the semicolon ;-)
> The particular case where I would enjoy shorter syntax is when using
> inlined functions in array extras.
> ----
> // assuming a is an array
> a.filter( (e)->(typeof e === "number" && e>3) )
> .map( (e)->(e*e) )
> .reduce( (prev, curr)->(prev+curr), 0);
Using ruby blocks' syntax (+6 versus +4 chars):
a.filter( {|e| typeof e === "number" && e>3})
.map( {|e| e*e } )
.reduce( {|prev, curr| prev+curr}, 0);
Is "{|" as a token likely to be found in any .js source file in the world, as of today ?
- Not in any object literal
- Not likely to be found at the beginning of a block.
- Inside a string it would not matter.
--
Jorge.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110507/4fbd3d4d/attachment.html>
More information about the es-discuss
mailing list