please add x .= f()
isiahmeadows at gmail.com
Tue Aug 11 07:41:59 UTC 2015
Okay... Maybe not CoffeeScript (don't normally use it), but I know a few
notable derivatives have that (particularly Coco and LiveScript).
As for the idea itself, still a -1 from me. Unless we add an equivalent for
every binary operator, it's not much of an addition. It's just another
special case, another band aid. Unless your identifier is 30+ characters, I
don't see much benefit. Unlike with numeric operators or string building,
this isn't nearly as common beyond that one case (string/array slicing).
And for a single character identifier, you're only really saving 1
character. 2 for 2-character identifiers.
There's also no performance gain from it, just sugar. And in the LiveScript
code I've seen (a language with this operator), I still rarely see it.
That's with a community that enjoys experimenting with the syntax, almost
gaming it at times. (Well, there was talk a few months ago about where
sugar can become a problem itself, especially when there's 2-3 ways to
write 7-8 basic constructs. )
On Mon, Aug 10, 2015, 22:27 Bergi <a.d.bergi at web.de> wrote:
> Isiah Meadows schrieb:
> > That's not really the point.
> > The suggestion is this instead:
> > ```js
> > if (s === '/') s = s.slice(1);
> > if (s === '/') s .= slice(1);
> > ```
> > This already exists in CoffeeScript and most derivatives/dialects.
> > ```coffee
> > s .= slice 1 if s is '/'
> > ```
> > Don't know of any other languages that have an equivalent, though.
> Really? Which version of CS, or which dialect are you using? It doesn't
> work for me in the online tool
> But if you're that much inclined to save single characters, I'd
> recommend to use
> s = s.slice(s == '/');
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss