domenic at domenicdenicola.com (2013-08-25T01:00:35.793Z)
On 21 August 2013 15:41, Erik Arvidsson <erik.arvidsson at gmail.com> wrote:
> One way to think of it is that the with is acting on a view of the
> object that does not have the blacklisted properties. This can be
> implemented using proxies. I'll leave that as an exercise.
I see.
>> * How would it interact with mutation?
>
> Another hole we didn't cover. Here is my proposal:
>
> The @@unscopable is only accessed once, when the object environment
> record is created.
Hm, that would seem rather inconsistent with the way adding/removing
properties can dynamically change the domain of a 'with'. Consider:
```js
function safeenrich(o) {
o.a = 1
o[@@unscopable] = o[@@unscopable] || []
o[@@unscopable].push('a')
}
let o = {}
let a = 0
with (o) {
a // 0
safeenrich(o)
a // 1
}
```
On 21 August 2013 15:41, Erik Arvidsson <erik.arvidsson at gmail.com> wrote: > One way to think of it is that the with is acting on a view of the > object that does not have the blacklisted properties. This can be > implemented using proxies. I'll leave that as an exercise. I see. >> * How would it interact with mutation? > > Another hole we didn't cover. Here is my proposal: > > The @@unscopable is only accessed once, when the object environment > record is created. Hm, that would seem rather inconsistent with the way adding/removing properties can dynamically change the domain of a 'with'. Consider: function safeenrich(o) { o.a = 1 o[@@unscopable] = o[@@unscopable] || [] o[@@unscopable].push('a') } let o = {} let a = 0 with (o) { a // 0 safeenrich(o) a // 1 } /Andreas