Arrow binding

Axel Rauschmayer axel at rauschma.de
Tue Apr 24 09:56:26 PDT 2012


Seems like a typo and Tab’s got it right. The advantage of a thin arrow (over a method definition) here is that you can do an implicit return and have slightly less to type. Given that method definitions don’t appear inside statements, I don’t see that as a problem.

AFAIK, an implicit return of the completion value of a method is out, because one might involuntary return wrong values (previously: undefined, now: completion value).

On Apr 24, 2012, at 18:51 , Rick Waldron wrote:

> 
> 
> On Tue, Apr 24, 2012 at 12:33 PM, Tab Atkins Jr. <jackalmage at gmail.com> wrote:
> On Mon, Apr 23, 2012 at 3:36 PM, David Herman <dherman at mozilla.com> wrote:
> > I'm much more sympathetic to the idea of having *two* shorter-function syntaxes, one optimized for methods and one optimized for non-method functions. I understand the concern about bloat, but to me it addresses the reality of different contexts in programming, e.g.:
> >
> >    a.map(x => x + 1)
> >
> > vs
> >
> >    box = {
> >        _value: 0,
> >        get: () -> this._value,
> >        set(v) { this._value = v }
> >    }
> 
> I don't understand this example.  What is "set(v) {...}"?  It's not a
> setter, because it's not associated with a property name.  Assuming
> you meant "set value(v) {...}", why not just use an ordinary getter as
> well?
> 
> When I read this, I assumed it was a reference to this: http://wiki.ecmascript.org/doku.php?id=harmony:object_literals#object_literal_property_shorthands
> 
> Which would produce a method named "set" on "box"
> 
> > box.set(42)
> > box.get()
> 
> 42
> 
> 
> The example is easily confused. 
> 
> Hope that helps
> 
> Rick
> 
> 
> 
>  
> 
> ~TJ
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120424/57473010/attachment-0001.html>


More information about the es-discuss mailing list