Re: [Proposal] Refer to actual value : keyword "itself"

2019-09-07 Thread Sultan
Can you currently do this with the "super" keyword outside of classes?

On Fri, Sep 6, 2019 at 9:16 PM Jordan Harband  wrote:

> `var itself = 3;` means that your choice of keyword wouldn't be an option;
> you'd be limited to something that was currently a syntax error.
>
> On Fri, Sep 6, 2019 at 2:53 AM Cyril Auburtin 
> wrote:
>
>> also optional-chaining will help
>> ```js
>> return {
>> ...state,
>> child: {
>> ...state?.child,
>> subchild: {
>> ...state?.child?.subchild,
>> property: (state?.child?.subchild?.property ?? 0) + 1
>> }
>> }
>> }
>> ```
>>
>> @Herby yes that's interesting, works in any order actually `const {child,
>> child: {subchild}} = state;`
>>
>> On Fri, Sep 6, 2019 at 11:23 AM Herby Vojčík  wrote:
>>
>>> On 6. 9. 2019 10:34, Cyril Auburtin wrote:
>>> > You could currently do
>>> > ```js
>>> > object.child.property /= 5
>>> > ```
>>> >
>>> > with destructuring:
>>> > ```js
>>> > const {child: {subchild}, child} = state;
>>>
>>> Wow, I didn't know I can do that. Nice.
>>>
>> ___
>> es-discuss mailing list
>> es-discuss@mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
> ___
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: [Proposal] Refer to actual value : keyword "itself"

2019-09-06 Thread Jordan Harband
`var itself = 3;` means that your choice of keyword wouldn't be an option;
you'd be limited to something that was currently a syntax error.

On Fri, Sep 6, 2019 at 2:53 AM Cyril Auburtin 
wrote:

> also optional-chaining will help
> ```js
> return {
> ...state,
> child: {
> ...state?.child,
> subchild: {
> ...state?.child?.subchild,
> property: (state?.child?.subchild?.property ?? 0) + 1
> }
> }
> }
> ```
>
> @Herby yes that's interesting, works in any order actually `const {child,
> child: {subchild}} = state;`
>
> On Fri, Sep 6, 2019 at 11:23 AM Herby Vojčík  wrote:
>
>> On 6. 9. 2019 10:34, Cyril Auburtin wrote:
>> > You could currently do
>> > ```js
>> > object.child.property /= 5
>> > ```
>> >
>> > with destructuring:
>> > ```js
>> > const {child: {subchild}, child} = state;
>>
>> Wow, I didn't know I can do that. Nice.
>>
> ___
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: [Proposal] Refer to actual value : keyword "itself"

2019-09-06 Thread Cyril Auburtin
also optional-chaining will help
```js
return {
...state,
child: {
...state?.child,
subchild: {
...state?.child?.subchild,
property: (state?.child?.subchild?.property ?? 0) + 1
}
}
}
```

@Herby yes that's interesting, works in any order actually `const {child,
child: {subchild}} = state;`

On Fri, Sep 6, 2019 at 11:23 AM Herby Vojčík  wrote:

> On 6. 9. 2019 10:34, Cyril Auburtin wrote:
> > You could currently do
> > ```js
> > object.child.property /= 5
> > ```
> >
> > with destructuring:
> > ```js
> > const {child: {subchild}, child} = state;
>
> Wow, I didn't know I can do that. Nice.
>
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: [Proposal] Refer to actual value : keyword "itself"

2019-09-06 Thread Herby Vojčík

On 6. 9. 2019 10:34, Cyril Auburtin wrote:

You could currently do
```js
object.child.property /= 5
```

with destructuring:
```js
const {child: {subchild}, child} = state;


Wow, I didn't know I can do that. Nice.
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: [Proposal] Refer to actual value : keyword "itself"

2019-09-06 Thread Imeian .
Yes of course I could use the /= operator in this simple example, but not
in more complex operations.

About itself in a property, it's correct : I mean itself to refer to the
actual value, the value being from a variable or an object property doesn't
matter. itself would not be a this equivalent, so whenever itself is used
it refers to the actual value we are assigning

Le ven. 6 sept. 2019 à 10:34, Cyril Auburtin  a
écrit :

> You could currently do
> ```js
> object.child.property /= 5
> ```
>
> with destructuring:
> ```js
> const {child: {subchild}, child} = state;
>
> return {
>   ...state,
>   child: {
> ...child,
> subchild: {
>   ...subchild,
>   property: subchild.property + 1
> }
>   }
> }
> ```
>
> or do-expressions:
> ```js
> return {
>   ...state,
>   child: do {
> const {child} = state;
> return {
>   ...child,
>   subchild: do {
> const {subchild} = child;
> return {
>   ...subchild,
>   property: subchild.property + 1
> };
>   }
> };
>   }
> }
> ```
>
> note: your `property: itself + 1` looks incorrect, since you probably mean
> to increment the `property` property
>
> On Fri, Sep 6, 2019 at 9:36 AM Imeian .  wrote:
>
>> When we need to change a value using the old value :
>>
>> variable = itself + 5 // instead of
>> variable = variable + 5
>>
>> object.child.property = itself / 5 // instead of
>> object.child.property = object.child.property / 5
>>
>> Changing a value in nested objects is a pain, like Redux states for eg.
>>
>> return {
>> ...state,
>> child: {
>> ...state.child,
>> subchild: {
>> ...state.child.subchild,
>> property: state.child.subchild.property + 1
>> }
>> }
>> }
>>
>> would then be
>>
>> return {
>> ...state,
>> child: {
>> ...itself,
>> subchild: {
>> ...itself,
>> property: itself + 1
>> }
>> }
>> }
>>
>>
>> ___
>> es-discuss mailing list
>> es-discuss@mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: [Proposal] Refer to actual value : keyword "itself"

2019-09-06 Thread Cyril Auburtin
Oops I forgot do-expression don't use `return`, so something, a bit ugly,
like:
```js
return {
  ...state,
  child: do {
const {child} = state;
({
  ...child,
  subchild: do {
const {subchild} = child;
({
  ...subchild,
  property: subchild.property + 1
});
  }
});
  }
}
```

On Fri, Sep 6, 2019 at 10:34 AM Cyril Auburtin 
wrote:

> You could currently do
> ```js
> object.child.property /= 5
> ```
>
> with destructuring:
> ```js
> const {child: {subchild}, child} = state;
>
> return {
>   ...state,
>   child: {
> ...child,
> subchild: {
>   ...subchild,
>   property: subchild.property + 1
> }
>   }
> }
> ```
>
> or do-expressions:
> ```js
> return {
>   ...state,
>   child: do {
> const {child} = state;
> return {
>   ...child,
>   subchild: do {
> const {subchild} = child;
> return {
>   ...subchild,
>   property: subchild.property + 1
> };
>   }
> };
>   }
> }
> ```
>
> note: your `property: itself + 1` looks incorrect, since you probably mean
> to increment the `property` property
>
> On Fri, Sep 6, 2019 at 9:36 AM Imeian .  wrote:
>
>> When we need to change a value using the old value :
>>
>> variable = itself + 5 // instead of
>> variable = variable + 5
>>
>> object.child.property = itself / 5 // instead of
>> object.child.property = object.child.property / 5
>>
>> Changing a value in nested objects is a pain, like Redux states for eg.
>>
>> return {
>> ...state,
>> child: {
>> ...state.child,
>> subchild: {
>> ...state.child.subchild,
>> property: state.child.subchild.property + 1
>> }
>> }
>> }
>>
>> would then be
>>
>> return {
>> ...state,
>> child: {
>> ...itself,
>> subchild: {
>> ...itself,
>> property: itself + 1
>> }
>> }
>> }
>>
>>
>> ___
>> es-discuss mailing list
>> es-discuss@mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: [Proposal] Refer to actual value : keyword "itself"

2019-09-06 Thread Cyril Auburtin
You could currently do
```js
object.child.property /= 5
```

with destructuring:
```js
const {child: {subchild}, child} = state;

return {
  ...state,
  child: {
...child,
subchild: {
  ...subchild,
  property: subchild.property + 1
}
  }
}
```

or do-expressions:
```js
return {
  ...state,
  child: do {
const {child} = state;
return {
  ...child,
  subchild: do {
const {subchild} = child;
return {
  ...subchild,
  property: subchild.property + 1
};
  }
};
  }
}
```

note: your `property: itself + 1` looks incorrect, since you probably mean
to increment the `property` property

On Fri, Sep 6, 2019 at 9:36 AM Imeian .  wrote:

> When we need to change a value using the old value :
>
> variable = itself + 5 // instead of
> variable = variable + 5
>
> object.child.property = itself / 5 // instead of
> object.child.property = object.child.property / 5
>
> Changing a value in nested objects is a pain, like Redux states for eg.
>
> return {
> ...state,
> child: {
> ...state.child,
> subchild: {
> ...state.child.subchild,
> property: state.child.subchild.property + 1
> }
> }
> }
>
> would then be
>
> return {
> ...state,
> child: {
> ...itself,
> subchild: {
> ...itself,
> property: itself + 1
> }
> }
> }
>
>
> ___
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


[Proposal] Refer to actual value : keyword "itself"

2019-09-06 Thread Imeian .
When we need to change a value using the old value :

variable = itself + 5 // instead of
variable = variable + 5

object.child.property = itself / 5 // instead of
object.child.property = object.child.property / 5

Changing a value in nested objects is a pain, like Redux states for eg.

return {
...state,
child: {
...state.child,
subchild: {
...state.child.subchild,
property: state.child.subchild.property + 1
}
}
}

would then be

return {
...state,
child: {
...itself,
subchild: {
...itself,
property: itself + 1
}
}
}
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss