Arrow binding

Rick Waldron waldron.rick at gmail.com
Tue Apr 24 09:51:04 PDT 2012


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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120424/665add5e/attachment.html>


More information about the es-discuss mailing list