simple shorter function syntax

Brendan Eich brendan at mozilla.com
Sat Jul 24 12:27:04 PDT 2010


On Jul 24, 2010, at 11:00 AM, Alex Russell wrote:

> On Jul 24, 2010, at 9:21 AM, Kevin Curtis wrote:
> 
>> Should the proposed shorter form # desugar to function or a const function:
>> http://wiki.ecmascript.org/doku.php?id=strawman:const_functions
> 
> Regular, plain-old function. No funky return semantics (ala some of the closure proposals), no extra qualifiers. If you want 'em, you can pay for 'em. The common problem "#" attempts to address is the huge verbosity of "function", nothing more.

That's not what the proposal from you and arv says :-/:

http://wiki.ecmascript.org/doku.php?id=strawman:shorter_function_syntax

The completion value of the statements in the braced body of a # function is the return value.


>> I dislike the verbosity of function - though I can't help feeling #
>> could be used for other ends.
>> 
>> let dict = #{"hello": 4, "world":5}; // it's a hash/dict not an object
> 
> So a new dictonary/map type is interesting, but it's unclear that we really need anything like that until/unless we turn off the "delete" operator.

Why wouldn't you ever delete from a dictionary?

The real motivator for dictionaries is to avoid Object.prototype pollution of the dict's "in" (not "own") property namespace.


>> let arr = #[4,4,5] // typed array - Numbers only - contiguous memory block?
> 
> How about we start with the long form for things that are currently uncommon and shorten them when they become painfully long to use?

Good in general if you can iterate quickly enough. If we can cut to the chase, even better given the cycle times among browsers and Ecma editions.

I see Kevin's point, too: use # for "hashes" and other object initialiser extensions, use something more lambda-looking for function.

/be


More information about the es-discuss mailing list