Shorthand for "function" keyword
tj.crowder at farsightsoftware.com
Fri Nov 10 15:08:11 UTC 2017
On Fri, Nov 10, 2017 at 2:58 PM, Laurentiu Taschina
<source.spider at gmail.com> wrote:
> So useless for callback usage, which a very big chunk of the use cases.
That's very different from the statement "only regular functions can have
names" but I can see how you got there. :-)
So naming inline callbacks is your primary motivation for this?
You're not going to have any luck getting `func`, `fn`, or `def` as a
keyword for this. Too much existing code would break. I'm certain I've used
all of those even just in my own code. Just about *any* short keyword is
going to have the same problem.
Which basically means we're back to the recurring theme of an
explicitly-named form for arrow functions (since you almost never want
`function` functions for inline callbacks anyway). That'll probably require
syntax rather than a keyword.
For instance, almost any flag character just inside the opening `(` could
work; an arrow seems apt:
const sum = [1, 2, 3].reduce((>add> a, b) => a + b);
...or backticks or quotes or... Technically one only needs an ending
delimiter, but it simplifies parsing (human and machine) if there's an
up-front indicator of a name; delimiters both sides (two characters) seems
reasonable. (If we really wanted to go wild, the same thing could be a
declaration form. *Ducks head and runs for cover.*)
It's a totally solvable problem, but I wonder if the will is there.
-- T.J. Crowder
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss