A shorthand for Object.defineProperty?

Axel Rauschmayer axel at rauschma.de
Mon Jun 20 16:31:20 PDT 2011


>> - Pro block-lambdas: A new construct that can be used in places where dynamic |this| (that normal functions are always going to have) would be a burden.
> 
> And for other purposes, such as block-like "bodies" of Array forEach, etc. methods.

Right, you want lexical |this| in these cases and the dynamic |this| (of regular functions) gets in the way. I consider that a benefit of block-lambdas (in addition to them having a compact syntax and their support for break etc.).

>> - Pro arrows: little semantic change.
> 
> No semantic change, I claim. What differs apart from syntax?

Correct. I meant “less semantic change” (that with block lambdas), but “no semantic change” puts it better.

>> With the shorthand for methods in object literals, there is the question whether dynamic |this| is ever needed.
> 
> This does not make sense.
> 
> Object literals used for prototypes have methods but those methods must use dynamic |this| because the calls use individual instances as their reference bases, not the prototype.

I meant: One can already write methods (functions with dynamic |this|) in a very concise manner, thanks for Allen’s object literal extensions. Then you have to ask: Do we really need the dynamic this arrow ->, or can we make do with just the lexical this arrow =>.

>> - Pro ƒ: short, syntactically very similar to current semantics *and* syntax.
> 
> The florin works no better than Greek lower-case lambda. Both are already legal ES3-5.1 Identifiers and cannot be retasked as keywords, especially not with the name of the function in a function expression optional.

Ah, damn, I knew it was a very convincing argument. ;-)
There is still the faint hope that this isn’t actually used in practice, but still.

-- 
Dr. Axel Rauschmayer

axel at rauschma.de
twitter.com/rauschma

home: rauschma.de
blog: 2ality.com



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110621/7b6dc901/attachment.html>


More information about the es-discuss mailing list