Allow Object Destructoring when assigning

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

Allow Object Destructoring when assigning

Sebastian Malton
Currently object destructoring is only allowed during variable declaration, however it would be useful, and seems rather odd from a usage standpoint, that it cannot be done during assignment. 

Example:
This is a allowed:
```
const { a } = b;
```

But this is not:
```
let a;

if (...) {
    { a } = b.c;
}
```

Sebastian Malton


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

Re: Allow Object Destructoring when assigning

Isiah Meadows-2
It's not easy to parse for similar reasons async arrow functions are a
bitch to parse, but it appears possible (it'd force a shift instead of
a reduce, and it'd reinterpret the RHS unambiguously as a pattern)
with a `[no LineTerminator here]` before the `=` token.
-----

Isiah Meadows
[hidden email]

Looking for web consulting? Or a new website?
Send me an email and we can get started.
www.isiahmeadows.com


On Thu, Mar 22, 2018 at 3:51 PM, Sebastian Malton <[hidden email]> wrote:

> Currently object destructoring is only allowed during variable declaration,
> however it would be useful, and seems rather odd from a usage standpoint,
> that it cannot be done during assignment.
>
> Example:
> This is a allowed:
> ```
> const { a } = b;
> ```
>
> But this is not:
> ```
> let a;
>
> if (...) {
>     { a } = b.c;
> }
> ```
>
> Sebastian Malton
>
>
> _______________________________________________
> 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: Allow Object Destructoring when assigning

Claude Pache
In reply to this post by Sebastian Malton


Le 22 mars 2018 à 20:51, Sebastian Malton <[hidden email]> a écrit :

Currently object destructoring is only allowed during variable declaration, however it would be useful, and seems rather odd from a usage standpoint, that it cannot be done during assignment. 

Example:
This is a allowed:
```
const { a } = b;
```

But this is not:
```
let a;

if (...) {
    { a } = b.c;
}
```

Sebastian Malton


This is already allowed, but you have to use some artefact in order to force the parser not to interpret`{` as the beginning of a block:

```
let a ;
({ a } = b);
```

—Claude 


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

Re: Allow Object Destructoring when assigning

Isiah Meadows-2
Oops...I misinterpreted the original email. :-)

As for forcing reinterpretation, I stand by my suggestion in an earlier reply:

> It's not easy to parse for similar reasons async arrow functions are a
> bitch to parse, but it appears possible (it'd force a shift instead of
> a reduce, and it'd reinterpret the RHS unambiguously as a pattern)
> with a `[no LineTerminator here]` before the `=` token.

-----

Isiah Meadows
[hidden email]

Looking for web consulting? Or a new website?
Send me an email and we can get started.
www.isiahmeadows.com


On Thu, Mar 22, 2018 at 5:49 PM, Claude Pache <[hidden email]> wrote:

>
>
> Le 22 mars 2018 à 20:51, Sebastian Malton <[hidden email]> a écrit :
>
> Currently object destructoring is only allowed during variable declaration,
> however it would be useful, and seems rather odd from a usage standpoint,
> that it cannot be done during assignment.
>
> Example:
> This is a allowed:
> ```
> const { a } = b;
> ```
>
> But this is not:
> ```
> let a;
>
> if (...) {
>     { a } = b.c;
> }
> ```
>
> Sebastian Malton
>
>
> This is already allowed, but you have to use some artefact in order to force
> the parser not to interpret`{` as the beginning of a block:
>
> ```
> let a ;
> ({ a } = b);
> ```
>
> —Claude
>
>
> _______________________________________________
> 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