Or maybe it would be

```js
theFunction(obj.&foo, obj.&bar);
```

to explicitly pass the particular properties, and would account for
nested properties too:

```js
theFunction(obj.foo.&bar, obj.lorem.&ipsum);
```

#!/JoePea

On Wed, Mar 3, 2021 at 6:29 PM #!/JoePea <[email protected]> wrote:
>
> I think it is a good idea, but maybe we need to think about what the
> final syntax would be. About segregation, if the library changes the
> signature, then they'll have the whole source object, right? Maybe for
> the mentioned security the user would need to opt in:
>
> ```js
> theFunction(&obj.foo, &obj.bar);
> ```
>
> would allow the function to destructure, and only destructure, by
> reference of those given properties, for example. Then the contract
> can not silently change from secure to insecure.
>
> #!/JoePea
>
> On Wed, Mar 3, 2021 at 9:47 AM Andrea Giammarchi
> <[email protected]> wrote:
> >
> > to expand further: you *could* access such reference via `arguments[0]`, 
> > but *that* won't be possible with arrow functions, as example, so that 
> > `({&reactive}, maybe) => { if (maybe) reactive = true; }` is another 
> > pattern that doesn't need the whole object around, or to be propagated, 
> > when you can pass it via `{&reactive}` to anything else, covering then the 
> > `arguments` point too.
> >
> > On Wed, Mar 3, 2021 at 6:44 PM Andrea Giammarchi 
> > <[email protected]> wrote:
> >>
> >> > the proposal is just a debatable syntax sugar for something we already 
> >> > can do
> >>
> >> that's basically the entirety of the syntax sugar proposals since ES2015, 
> >> right? also proxy and globalThis are *really* unrelated to this, imho, 
> >> while leaking objects all over down the pipe is my major concern, 
> >> something this proposal avoids, as no code will have a reference to the 
> >> entirety of the source object, they'll deal with a known property name 
> >> passed by reference, incapable of changing anything else in the source 
> >> object ... so it's rather a signal, than a convention.
> >>
> >> this means composability, different classes/prototypes passed as 
> >> arguments, and the certainty nothing can inspect, change, or deal, with 
> >> the source, which means increased security, as opposite to pass instances 
> >> and whole objects references around.
> >>
> >> You have a reference to a property, you don't see its source.
> >>
> >>
> >> On Wed, Mar 3, 2021 at 6:19 PM Augusto Moura <[email protected]> 
> >> wrote:
> >>>
> >>> > ```js
> >>> > function stuff(source, extra) {
> >>> >   const {value, method} = source;
> >>> >
> >>> >   if (condition)
> >>> >     method.call(source);
> >>> >
> >>> >   if (value === extra)
> >>> >     source.value = 'no more';
> >>> > }
> >>> > ```
> >>>
> >>> I mean, in this case you can skip destructuring altogether, having a one 
> >>> way and way only of value indirection is a Pretty Good Thing™ (even 
> >>> though we already have proxys, globalThis and other indirection 
> >>> shenanigans), I never felt annoyed of just using `source.value` or 
> >>> `source.method()` instead of `value` and `method()`, again the proposal 
> >>> is just a debatable syntax sugar for something we already can do. I 
> >>> wonder if we could ever do the reference thingy in user-land with 
> >>> variable level decorators, if it ever gets discussed again in the 
> >>> meetings. Would be still kinda fishy to propose and implement
> >
> > _______________________________________________
> > es-discuss mailing list
> > [email protected]
> > https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to