please add x .= f()

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

please add x .= f()

Soni L.
x .= f() should be syntax sugar for x = x.f()

x .= f().g().h() should be x = x.f().g().h()

--
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: please add x .= f()

Bucaran
-1 Please no :)

> On Aug 11, 2015, at 2:40 AM, Soni L. <[hidden email]> wrote:
>
> x .= f() should be syntax sugar for x = x.f()
>
> x .= f().g().h() should be x = x.f().g().h()
>
> --
> Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.
>
> _______________________________________________
> es-discuss mailing list
> [hidden email]
> https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: please add x .= f()

Florent FAYOLLE
Hello,
> x .= f() should be syntax sugar for x = x.f()
>
> x .= f().g().h() should be x = x.f().g().h()

+1! I've made some weeks ago a prototype of this in sweet.js:
https://github.com/fflorent/member-access-assignment

Except that the syntax is rather =. (I have probably been influenced by
the CoffeeScript's existential operator). The reverse looks fine to me too.

> -1 Please no :)
Why?

Florent
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: please add x .= f()

Andrea Giammarchi-2
In reply to this post by Bucaran
I want to +1 the -1, but I'll add a

Please no

instead as well.

On Mon, Aug 10, 2015 at 6:42 PM, Bucaran <[hidden email]> wrote:
-1 Please no :)

> On Aug 11, 2015, at 2:40 AM, Soni L. <[hidden email]> wrote:
>
> x .= f() should be syntax sugar for x = x.f()
>
> x .= f().g().h() should be x = x.f().g().h()
>
> --
> Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.
>
> _______________________________________________
> es-discuss mailing list
> [hidden email]
> https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: please add x .= f()

Brendan Eich-2
In reply to this post by Florent FAYOLLE
Do not send "Please add" messages with two-line, half-baked sketches of
extensions to the language. That's just injecting noise with very little
signal.

The "-1" you received will be the answer if pressed from everyone on
TC39, I would bet real money. Syntax is expensive, adding it for little
semantic gain and some downside user-confusion risk (plus a small
complexity tax hike for the language in full) is never the right answer.

That you can scratch this itch (and many others like it) via sweet.js
does not argue for incorporating any such =. or .= operator into the
core language. Analyze developer patterns and nearby languages for
better candidate extensions that solve more serious usability or greater
issues.

/be

Florent FAYOLLE wrote:

> Hello,
>> x .= f() should be syntax sugar for x = x.f()
>>
>> x .= f().g().h() should be x = x.f().g().h()
>
> +1! I've made some weeks ago a prototype of this in sweet.js:
> https://github.com/fflorent/member-access-assignment
>
> Except that the syntax is rather =. (I have probably been influenced
> by the CoffeeScript's existential operator). The reverse looks fine to
> me too.
>
>> -1 Please no :)
> Why?
>
> Florent
> _______________________________________________
> es-discuss mailing list
> [hidden email]
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: please add x .= f()

myemailum14
Please no, while i can see how logically it's derived from a = a + 1 

a = a.f()

a .= f()

seems like a bad idea

i can hardly see the dot
why would i replace the object from which i'm calling the method in most cases looks inefficient


On Mon, Aug 10, 2015 at 2:07 PM, Brendan Eich <[hidden email]> wrote:
Do not send "Please add" messages with two-line, half-baked sketches of extensions to the language. That's just injecting noise with very little signal.

The "-1" you received will be the answer if pressed from everyone on TC39, I would bet real money. Syntax is expensive, adding it for little semantic gain and some downside user-confusion risk (plus a small complexity tax hike for the language in full) is never the right answer.

That you can scratch this itch (and many others like it) via sweet.js does not argue for incorporating any such =. or .= operator into the core language. Analyze developer patterns and nearby languages for better candidate extensions that solve more serious usability or greater issues.

/be


Florent FAYOLLE wrote:
Hello,
x .= f() should be syntax sugar for x = x.f()

x .= f().g().h() should be x = x.f().g().h()

+1! I've made some weeks ago a prototype of this in sweet.js:
https://github.com/fflorent/member-access-assignment

Except that the syntax is rather =. (I have probably been influenced by the CoffeeScript's existential operator). The reverse looks fine to me too.

-1 Please no :)
Why?

Florent
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: please add x .= f()

Alexander Jones
In reply to this post by Soni L.
Not sure if trolling...

On Monday, 10 August 2015, Soni L. <[hidden email]> wrote:
x .= f() should be syntax sugar for x = x.f()

x .= f().g().h() should be x = x.f().g().h()

--
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: please add x .= f()

Andrea Giammarchi-2
In reply to this post by myemailum14
not only it's badly readable and reminds me the PHP string concatenation,
but it promotes different type assignment which is a performance, and virtually strongly typed, anti-pattern.

I think Brendan said already it all, the proposal is badly described, and it solve pretty much nothing in the real world.

Probably we can just move on and ignore the list of -1 we'll all put in? ;-)

Best Regards

On Mon, Aug 10, 2015 at 8:46 PM, <[hidden email]> wrote:
Please no, while i can see how logically it's derived from a = a + 1 

a = a.f()

a .= f()

seems like a bad idea

i can hardly see the dot
why would i replace the object from which i'm calling the method in most cases looks inefficient


On Mon, Aug 10, 2015 at 2:07 PM, Brendan Eich <[hidden email]> wrote:
Do not send "Please add" messages with two-line, half-baked sketches of extensions to the language. That's just injecting noise with very little signal.

The "-1" you received will be the answer if pressed from everyone on TC39, I would bet real money. Syntax is expensive, adding it for little semantic gain and some downside user-confusion risk (plus a small complexity tax hike for the language in full) is never the right answer.

That you can scratch this itch (and many others like it) via sweet.js does not argue for incorporating any such =. or .= operator into the core language. Analyze developer patterns and nearby languages for better candidate extensions that solve more serious usability or greater issues.

/be


Florent FAYOLLE wrote:
Hello,
x .= f() should be syntax sugar for x = x.f()

x .= f().g().h() should be x = x.f().g().h()

+1! I've made some weeks ago a prototype of this in sweet.js:
https://github.com/fflorent/member-access-assignment

Except that the syntax is rather =. (I have probably been influenced by the CoffeeScript's existential operator). The reverse looks fine to me too.

-1 Please no :)
Why?

Florent
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: please add x .= f()

Andrea Giammarchi-2
In reply to this post by Alexander Jones
had same feeling just reading the initial email ... fakedme+es@ ... 

On Mon, Aug 10, 2015 at 8:50 PM, Alexander Jones <[hidden email]> wrote:
Not sure if trolling...

On Monday, 10 August 2015, Soni L. <[hidden email]> wrote:
x .= f() should be syntax sugar for x = x.f()

x .= f().g().h() should be x = x.f().g().h()

--
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: please add x .= f()

Soni L.
In reply to this post by Andrea Giammarchi-2
Welp I keep replying this wrong (how should I configure my email client?)
-------------------------------------------------------------------------

It /could/ in theory be used like this:

function path(s) {
  if (s.charAt(0) == '/') { s.=substring(1); }
  // your stuff here
}


On 10/08/15 04:50 PM, Andrea Giammarchi wrote:
not only it's badly readable and reminds me the PHP string concatenation,
but it promotes different type assignment which is a performance, and virtually strongly typed, anti-pattern.

I think Brendan said already it all, the proposal is badly described, and it solve pretty much nothing in the real world.

Probably we can just move on and ignore the list of -1 we'll all put in? ;-)

Best Regards

On Mon, Aug 10, 2015 at 8:46 PM, <[hidden email]> wrote:
Please no, while i can see how logically it's derived from a = a + 1 

a = a.f()

a .= f()

seems like a bad idea

i can hardly see the dot
why would i replace the object from which i'm calling the method in most cases looks inefficient


On Mon, Aug 10, 2015 at 2:07 PM, Brendan Eich <[hidden email]> wrote:
Do not send "Please add" messages with two-line, half-baked sketches of extensions to the language. That's just injecting noise with very little signal.

The "-1" you received will be the answer if pressed from everyone on TC39, I would bet real money. Syntax is expensive, adding it for little semantic gain and some downside user-confusion risk (plus a small complexity tax hike for the language in full) is never the right answer.

That you can scratch this itch (and many others like it) via sweet.js does not argue for incorporating any such =. or .= operator into the core language. Analyze developer patterns and nearby languages for better candidate extensions that solve more serious usability or greater issues.

/be


Florent FAYOLLE wrote:
Hello,
x .= f() should be syntax sugar for x = x.f()

x .= f().g().h() should be x = x.f().g().h()

+1! I've made some weeks ago a prototype of this in sweet.js:
https://github.com/fflorent/member-access-assignment

Except that the syntax is rather =. (I have probably been influenced by the CoffeeScript's existential operator). The reverse looks fine to me too.

-1 Please no :)
Why?

Florent
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

-- 
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: please add x .= f()

Jordan Harband
For that, you'd do `if (s.charAt(0) === '/') { s = s.slice(1); }` - which is only slightly more verbose than your example, without the burden of new syntax.

On Mon, Aug 10, 2015 at 1:57 PM, Soni L. <[hidden email]> wrote:
Welp I keep replying this wrong (how should I configure my email client?)
-------------------------------------------------------------------------

It /could/ in theory be used like this:

function path(s) {
  if (s.charAt(0) == '/') { s.=substring(1); }
  // your stuff here
}


On 10/08/15 04:50 PM, Andrea Giammarchi wrote:
not only it's badly readable and reminds me the PHP string concatenation,
but it promotes different type assignment which is a performance, and virtually strongly typed, anti-pattern.

I think Brendan said already it all, the proposal is badly described, and it solve pretty much nothing in the real world.

Probably we can just move on and ignore the list of -1 we'll all put in? ;-)

Best Regards

On Mon, Aug 10, 2015 at 8:46 PM, <[hidden email]> wrote:
Please no, while i can see how logically it's derived from a = a + 1 

a = a.f()

a .= f()

seems like a bad idea

i can hardly see the dot
why would i replace the object from which i'm calling the method in most cases looks inefficient


On Mon, Aug 10, 2015 at 2:07 PM, Brendan Eich <[hidden email][hidden email]> wrote:
Do not send "Please add" messages with two-line, half-baked sketches of extensions to the language. That's just injecting noise with very little signal.

The "-1" you received will be the answer if pressed from everyone on TC39, I would bet real money. Syntax is expensive, adding it for little semantic gain and some downside user-confusion risk (plus a small complexity tax hike for the language in full) is never the right answer.

That you can scratch this itch (and many others like it) via sweet.js does not argue for incorporating any such =. or .= operator into the core language. Analyze developer patterns and nearby languages for better candidate extensions that solve more serious usability or greater issues.

/be


Florent FAYOLLE wrote:
Hello,
x .= f() should be syntax sugar for x = x.f()

x .= f().g().h() should be x = x.f().g().h()

+1! I've made some weeks ago a prototype of this in sweet.js:
https://github.com/fflorent/member-access-assignment

Except that the syntax is rather =. (I have probably been influenced by the CoffeeScript's existential operator). The reverse looks fine to me too.

-1 Please no :)
Why?

Florent
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

-- 
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: please add x .= f()

Isiah Meadows-2

That's not really the point.

The suggestion is this instead:

```js
if (s[0] === '/') s = s.slice(1);
if (s[0] === '/') s .= slice(1);
```

This already exists in CoffeeScript and most derivatives/dialects.

```coffee
s .= slice 1 if s[0] is '/'
```

Don't know of any other languages that have an equivalent, though.


On Mon, Aug 10, 2015, 19:31 Jordan Harband <[hidden email]> wrote:
For that, you'd do `if (s.charAt(0) === '/') { s = s.slice(1); }` - which is only slightly more verbose than your example, without the burden of new syntax.

On Mon, Aug 10, 2015 at 1:57 PM, Soni L. <[hidden email]> wrote:
Welp I keep replying this wrong (how should I configure my email client?)
-------------------------------------------------------------------------

It /could/ in theory be used like this:

function path(s) {
  if (s.charAt(0) == '/') { s.=substring(1); }
  // your stuff here
}


On 10/08/15 04:50 PM, Andrea Giammarchi wrote:
not only it's badly readable and reminds me the PHP string concatenation,
but it promotes different type assignment which is a performance, and virtually strongly typed, anti-pattern.

I think Brendan said already it all, the proposal is badly described, and it solve pretty much nothing in the real world.

Probably we can just move on and ignore the list of -1 we'll all put in? ;-)

Best Regards

On Mon, Aug 10, 2015 at 8:46 PM, <[hidden email]> wrote:
Please no, while i can see how logically it's derived from a = a + 1 

a = a.f()

a .= f()

seems like a bad idea

i can hardly see the dot
why would i replace the object from which i'm calling the method in most cases looks inefficient


On Mon, Aug 10, 2015 at 2:07 PM, Brendan Eich <[hidden email][hidden email]> wrote:
Do not send "Please add" messages with two-line, half-baked sketches of extensions to the language. That's just injecting noise with very little signal.

The "-1" you received will be the answer if pressed from everyone on TC39, I would bet real money. Syntax is expensive, adding it for little semantic gain and some downside user-confusion risk (plus a small complexity tax hike for the language in full) is never the right answer.

That you can scratch this itch (and many others like it) via sweet.js does not argue for incorporating any such =. or .= operator into the core language. Analyze developer patterns and nearby languages for better candidate extensions that solve more serious usability or greater issues.

/be


Florent FAYOLLE wrote:
Hello,
x .= f() should be syntax sugar for x = x.f()

x .= f().g().h() should be x = x.f().g().h()

+1! I've made some weeks ago a prototype of this in sweet.js:
https://github.com/fflorent/member-access-assignment

Except that the syntax is rather =. (I have probably been influenced by the CoffeeScript's existential operator). The reverse looks fine to me too.

-1 Please no :)
Why?

Florent
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

-- 
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: please add x .= f()

Iago Sousa
I vote for no. There is no performance gain and I can hardly see anyone using it.
Em seg, 10 de ago de 2015 às 22:18, Isiah Meadows <[hidden email]> escreveu:

That's not really the point.

The suggestion is this instead:

```js
if (s[0] === '/') s = s.slice(1);
if (s[0] === '/') s .= slice(1);
```

This already exists in CoffeeScript and most derivatives/dialects.

```coffee
s .= slice 1 if s[0] is '/'
```

Don't know of any other languages that have an equivalent, though.


On Mon, Aug 10, 2015, 19:31 Jordan Harband <[hidden email]> wrote:
For that, you'd do `if (s.charAt(0) === '/') { s = s.slice(1); }` - which is only slightly more verbose than your example, without the burden of new syntax.

On Mon, Aug 10, 2015 at 1:57 PM, Soni L. <[hidden email]> wrote:
Welp I keep replying this wrong (how should I configure my email client?)
-------------------------------------------------------------------------

It /could/ in theory be used like this:

function path(s) {
  if (s.charAt(0) == '/') { s.=substring(1); }
  // your stuff here
}


On 10/08/15 04:50 PM, Andrea Giammarchi wrote:
not only it's badly readable and reminds me the PHP string concatenation,
but it promotes different type assignment which is a performance, and virtually strongly typed, anti-pattern.

I think Brendan said already it all, the proposal is badly described, and it solve pretty much nothing in the real world.

Probably we can just move on and ignore the list of -1 we'll all put in? ;-)

Best Regards

On Mon, Aug 10, 2015 at 8:46 PM, <[hidden email]> wrote:
Please no, while i can see how logically it's derived from a = a + 1 

a = a.f()

a .= f()

seems like a bad idea

i can hardly see the dot
why would i replace the object from which i'm calling the method in most cases looks inefficient


On Mon, Aug 10, 2015 at 2:07 PM, Brendan Eich <[hidden email][hidden email]> wrote:
Do not send "Please add" messages with two-line, half-baked sketches of extensions to the language. That's just injecting noise with very little signal.

The "-1" you received will be the answer if pressed from everyone on TC39, I would bet real money. Syntax is expensive, adding it for little semantic gain and some downside user-confusion risk (plus a small complexity tax hike for the language in full) is never the right answer.

That you can scratch this itch (and many others like it) via sweet.js does not argue for incorporating any such =. or .= operator into the core language. Analyze developer patterns and nearby languages for better candidate extensions that solve more serious usability or greater issues.

/be


Florent FAYOLLE wrote:
Hello,
x .= f() should be syntax sugar for x = x.f()

x .= f().g().h() should be x = x.f().g().h()

+1! I've made some weeks ago a prototype of this in sweet.js:
https://github.com/fflorent/member-access-assignment

Except that the syntax is rather =. (I have probably been influenced by the CoffeeScript's existential operator). The reverse looks fine to me too.

-1 Please no :)
Why?

Florent
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

-- 
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
--
Iago Sousa

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: please add x .= f()

Bergi
In reply to this post by Isiah Meadows-2
Isiah Meadows schrieb:

> That's not really the point.
>
> The suggestion is this instead:
>
> ```js
> if (s[0] === '/') s = s.slice(1);
> if (s[0] === '/') s .= slice(1);
> ```
>
> This already exists in CoffeeScript and most derivatives/dialects.
>
> ```coffee
> s .= slice 1 if s[0] 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
<http://coffeescript.org/#try:s%20%3D%20%22%2Fsomething%22%0As%20.%3D%20slice%201%20if%20s%5B0%5D%20is%20'%2F'>.

But if you're that much inclined to save single characters, I'd
recommend to use
```js
s = s.slice(s[0] == '/');
```

  Bergi
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: please add x .= f()

Isiah Meadows-2

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. [1])

[1]: https://github.com/gkz/LiveScript/issues/721


On Mon, Aug 10, 2015, 22:27 Bergi <[hidden email]> wrote:
Isiah Meadows schrieb:
> That's not really the point.
>
> The suggestion is this instead:
>
> ```js
> if (s[0] === '/') s = s.slice(1);
> if (s[0] === '/') s .= slice(1);
> ```
>
> This already exists in CoffeeScript and most derivatives/dialects.
>
> ```coffee
> s .= slice 1 if s[0] 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
<<a href="http://coffeescript.org/#try:s%20%3D%20%22%2Fsomething%22%0As%20.%3D%20slice%201%20if%20s%5B0%5D%20is%20&#39;%2F" rel="noreferrer" target="_blank">http://coffeescript.org/#try:s%20%3D%20%22%2Fsomething%22%0As%20.%3D%20slice%201%20if%20s%5B0%5D%20is%20'%2F'>.

But if you're that much inclined to save single characters, I'd
recommend to use
```js
s = s.slice(s[0] == '/');
```

  Bergi
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss