On 04/17/2018 02:26 PM, Sultan wrote:
In the transpilation you created the field using "registry.set(this, {id: 0})"
in the constructor.  If you then claim that any write to the field can also 
create it, then you get the hijacking behavior which you wrote doesn't happen.

The difference between

class A {
   private id = 0
}

and

class A {
   constructor() {
private.id <http://private.id> = 0
   }
}

is the likened to the difference between

(function (){
   var registry = WeakMap()

   function A () {
     registry.set(this, {id: 0})
   }

   return A
})()

and

(function () {
   var registry = WeakMap()

   function A () {
     registry.set(this, {})
     registry.get(this)["id"] = 0
   }

   return A
})

I don't see how this permits the hijacking behavior previously mentioned, that 
is –

(new A()).write.call({}, 'pawned');

Would still fail in the same way for both of these variants.

OK; you split creation into two phases.  That's fine.  Do you limit classes to 
creating only the private fields declared in the class, or can they create 
arbitrarily named ones?

They just lexically scope the private names in their own separate namespace.  
#foo refers to the innermost enclosing class that has a private field called 
foo.

I'm not sure i understand, Does #foo refer to this.#foo? Can you post a fleshed 
out example of this?

The full form is expr.#foo, where expr can be `this` or some other expression 
appropriate in front of a dot.  The #foo binds to the innermost enclosing class 
that has a private field called foo.  If expr doesn't evaluate to an instance 
of that class, you fail and throw.

Read the proposals.

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

Reply via email to