{"action":"created","issue":{"url":"https://api.github.com/repos/tc39/proposal-class-fields/issues/158","repository_url":"https://api.github.com/repos/tc39/proposal-class-fields","labels_url":"https://api.github.com/repos/tc39/proposal-class-fields/issues/158/labels{/name}","comments_url":"https://api.github.com/repos/tc39/proposal-class-fields/issues/158/comments","events_url":"https://api.github.com/repos/tc39/proposal-class-fields/issues/158/events","html_url":"https://github.com/tc39/proposal-class-fields/issues/158","id":372666517,"node_id":"MDU6SXNzdWUzNzI2NjY1MTc=","number":158,"title":"Private fields/properties & the membrane pattern...","user":{"login":"rdking","id":2289634,"node_id":"MDQ6VXNlcjIyODk2MzQ=","avatar_url":"https://avatars0.githubusercontent.com/u/2289634?v=4","gravatar_id":"","url":"https://api.github.com/users/rdking","html_url":"https://github.com/rdking","followers_url":"https://api.github.com/users/rdking/followers","following_url":"https://api.github.com/users/rdking/following{/other_user}","gists_url":"https://api.github.com/users/rdking/gists{/gist_id}","starred_url":"https://api.github.com/users/rdking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rdking/subscriptions","organizations_url":"https://api.github.com/users/rdking/orgs","repos_url":"https://api.github.com/users/rdking/repos","events_url":"https://api.github.com/users/rdking/events{/privacy}","received_events_url":"https://api.github.com/users/rdking/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":60,"created_at":"2018-10-22T19:37:20Z","updated_at":"2018-12-31T01:45:33Z","closed_at":null,"author_association":"NONE","body":"Ok. Can someone explain to me what the difficulty is with the membrane pattern and private fields, because I'm not sure that I understand the problem at all. For me, it seems fairly obvious that the correct choice is to tunnel private field access through Proxy. If private fields are supposed to be completely transparent to running code other than `Function.prototype.toString`, then Proxy should forward all requests involving a \"PrivateName\" through to the corresponding `Reflect` handler.\r\n\r\nSo what am I missing?\r\n\r\nI get that there's some concern that tunneling will expose private fields and allow data to pass through the membrane unwrapped, but I just don't see how.\r\n\r\n```js\r\nclass Ex {\r\n  #foo = { foo: \"bar\"};\r\n  method() { return this.#foo; }\r\n}\r\nvar mHandler = {\r\n  data: new WeakMap(),\r\n  get(target, prop, receiver) {\r\n    var retval = Reflect.get(target, prop.receiver);\r\n    if (prop == \"isProxy\") {\r\n      retval = true;\r\n    }\r\n    else {\r\n      retval = new Proxy(retval, mHandler);\r\n    }\r\n    return retval;\r\n  },\r\n  set(target, prop, val, receiver) {\r\n    if (val && [\"object\",\"function\"].includes(typeof(val))) {\r\n      val = new Proxy(val, mHandler);\r\n    }\r\n    return Reflect.set(target, prop, val, receiver);\r\n  },\r\n  apply(target, thisArg, args) {\r\n    var _this = mHandler.data.get(thisArg) || thisArg;\r\n    for (var i=0; i<args.length; ++i) {\r\n      if (!args[i].isProxy) {\r\n        args[i] = new Proxy(args[i], mHandler);\r\n      }\r\n    }\r\n    var retval = Reflect.apply(target, _this, args)\r\n    if (retval && [\"object\",\"function\"].includes(typeof(retval))) {\r\n      retval = new Proxy(retval, mHandler);\r\n    }\r\n    return retval;\r\n  }\r\n};\r\nconst MEx = new Proxy(Ex, {\r\n  construct(target, args, newTarget) {\r\n    var result = Reflect.construct(target, args, newTarget);\r\n    var retval = new Proxy(result, mHandler);\r\n    mHandler.data.set(result, retval);\r\n    mHandler.data.set(retval, result);\r\n    return retval;\r\n  }\r\n});\r\n\r\nvar ex = new MEx();\r\nconsole.log(`ex.foo = ${JSON.stringify(ex.method(), null, '\\t')}`);\r\nconsole.log(`ex is a proxy = ${!!ex.isProxy}`);\r\n```\r\nIf private fields were allowed to tunnel, I don't see how I'd get back anything other than:\r\n```js\r\nex.foo = {\r\n  foo: \"bar\"\r\n}\r\nex is a proxy = true\r\n```"},"comment":{"url":"https://api.github.com/repos/tc39/proposal-class-fields/issues/comments/450600353","html_url":"https://github.com/tc39/proposal-class-fields/issues/158#issuecomment-450600353","issue_url":"https://api.github.com/repos/tc39/proposal-class-fields/issues/158","id":450600353,"node_id":"MDEyOklzc3VlQ29tbWVudDQ1MDYwMDM1Mw==","user":{"login":"isiahmeadows","id":4483844,"node_id":"MDQ6VXNlcjQ0ODM4NDQ=","avatar_url":"https://avatars1.githubusercontent.com/u/4483844?v=4","gravatar_id":"","url":"https://api.github.com/users/isiahmeadows","html_url":"https://github.com/isiahmeadows","followers_url":"https://api.github.com/users/isiahmeadows/followers","following_url":"https://api.github.com/users/isiahmeadows/following{/other_user}","gists_url":"https://api.github.com/users/isiahmeadows/gists{/gist_id}","starred_url":"https://api.github.com/users/isiahmeadows/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isiahmeadows/subscriptions","organizations_url":"https://api.github.com/users/isiahmeadows/orgs","repos_url":"https://api.github.com/users/isiahmeadows/repos","events_url":"https://api.github.com/users/isiahmeadows/events{/privacy}","received_events_url":"https://api.github.com/users/isiahmeadows/received_events","type":"User","site_admin":false},"created_at":"2018-12-31T01:45:33Z","updated_at":"2018-12-31T01:45:33Z","author_association":"NONE","body":"@erights \r\n\r\n> So why not have it be a WeakMap-like or PrivateName-like special object instead of a Symbol-like special primitive?\r\n\r\n@zenparsing has a separate proposal related to this: https://github.com/zenparsing/proposal-virtual-properties"}}
{"actor":{"display_login":"isiahmeadows"}}