Syntactic sugar for using a function as if it were a method of its first argument

C. Scott Ananian ecmascript at cscott.net
Tue May 27 10:12:26 PDT 2014


I like the idea, but I agree that the .{ } syntax isn't quite right.  For
one thing, on my screen the () are visually very similar to {}, while []
are easily distinguished.  The leading dot is also a bit odd.  I'd be
interested in seeing some more alternative syntaxes for this idea.
  --scott


On Tue, May 27, 2014 at 8:54 AM, Claude Pache <claude.pache at gmail.com>wrote:

>
> Le 27 mai 2014 à 17:04, Jasper St. Pierre <jstpierre at mecheye.net> a écrit
> :
>
> >
> > (...) Namely, the whole ('elements') looks like a method call containing
> one argument, rather than having a secret hidden argument as its first.
> >
>
> Yes, it was exactly intended to appear as such, making
> `obj.{Object.getOwnPropertyDescriptor}('elements')` similar to
> `obj.hasOwnProperty('elements')`, for instance. If it helps, you could
> think of `foo.{Bar.baz}` as defining a temporary method:
> `(function(...args) { return Bar.baz(this, ...args) })`, or:
> `Bar.baz.bind(Bar, foo)`.
>
> —Claude
>
> _______________________________________________
> 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/20140527/d1bc014d/attachment-0001.html>


More information about the es-discuss mailing list