{"action":"created","issue":{"url":"https://api.github.com/repos/tc39/proposal-class-fields/issues/195","repository_url":"https://api.github.com/repos/tc39/proposal-class-fields","labels_url":"https://api.github.com/repos/tc39/proposal-class-fields/issues/195/labels{/name}","comments_url":"https://api.github.com/repos/tc39/proposal-class-fields/issues/195/comments","events_url":"https://api.github.com/repos/tc39/proposal-class-fields/issues/195/events","html_url":"https://github.com/tc39/proposal-class-fields/issues/195","id":395138326,"node_id":"MDU6SXNzdWUzOTUxMzgzMjY=","number":195,"title":"The concept of \"access mode\" (was: Not leaving protected behind in the dust)","user":{"login":"trusktr","id":297678,"node_id":"MDQ6VXNlcjI5NzY3OA==","avatar_url":"https://avatars3.githubusercontent.com/u/297678?v=4","gravatar_id":"","url":"https://api.github.com/users/trusktr","html_url":"https://github.com/trusktr","followers_url":"https://api.github.com/users/trusktr/followers","following_url":"https://api.github.com/users/trusktr/following{/other_user}","gists_url":"https://api.github.com/users/trusktr/gists{/gist_id}","starred_url":"https://api.github.com/users/trusktr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trusktr/subscriptions","organizations_url":"https://api.github.com/users/trusktr/orgs","repos_url":"https://api.github.com/users/trusktr/repos","events_url":"https://api.github.com/users/trusktr/events{/privacy}","received_events_url":"https://api.github.com/users/trusktr/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2019-01-02T02:55:50Z","updated_at":"2019-01-02T18:43:45Z","closed_at":"2019-01-02T08:19:09Z","author_association":"NONE","body":"(this first post was about having both private and protected with similar syntax, but the next comments evolved into the concept of \"access mode\")\r\n\r\nPersonally I like the more poetic/verbose/meaningfully-clear `private`/`protected` keywords, and my editor's autocompletion is fast enough (if my typing speed can't beat it).\r\n\r\nBut if we're going to stick with the `#` sigil, can we at least figure how `protected` will be allowed the possibility of entering the picture later (if it ever does), without it being asymmetrical? (f.e. `#` for private and `protected` for protected wouldn't be symmetrical)\r\n\r\nWhat about having both `#` and `##`?\r\n\r\nI feel like `#` for protected and `##` for private would be nice. The longer one with _**more**_ symbols is for private because `private` is _**more**_ hidden than `protected`.\r\n\r\n```js\r\nclass Foo {\r\n    publicMethod() {\r\n        this.##privateMethod()\r\n        this[##'private'+'Method']()\r\n    }\r\n    #protectedMethod() {}\r\n    ##privateMethod() {}\r\n}\r\n\r\nclass Bar extends Foo {\r\n    publicMethod() {\r\n        super.publicMethod()\r\n        super['public'+'Method']()\r\n        \r\n        this.#protectedMethod()\r\n        this[#'protected'+'Method']()\r\n    }\r\n}\r\n\r\nconst bar = new Bar\r\nbar.publicMethod()\r\nbar['public'+'Method']()\r\n```\r\n\r\nPersonally I would be fine losing the `.` symbol when accessing protected or private:\r\n\r\n```js\r\n        super.publicMethod()\r\n        super['public'+'Method']()\r\n        this##privateMethod()\r\n        this[##'private'+'Method']()\r\n        this#protectedMethod()\r\n        this[#'protected'+'Method']()\r\n```\r\n\r\nFor dynamic string access, and alternative could be the `#` symbols go outside:\r\n\r\n```js\r\n        super.publicMethod()\r\n        super['public'+'Method']()\r\n        this##privateMethod()\r\n        this##['private'+'Method']()\r\n        this#protectedMethod()\r\n        this#['protected'+'Method']()\r\n```\r\n\r\nor\r\n\r\n```js\r\n        super.publicMethod()\r\n        super['public'+'Method']()\r\n        this.##privateMethod()\r\n        this##['private'+'Method']()\r\n        this.#protectedMethod()\r\n        this#['protected'+'Method']()\r\n```\r\n\r\nBut that last one is the most awkward. If we want to preserve the notion of accessing props on an object with `.`, then another possibility is:\r\n\r\n```js\r\n        super.publicMethod()\r\n        super['public'+'Method']()\r\n        this##.privateMethod()\r\n        this##['private'+'Method']()\r\n        this#.protectedMethod()\r\n        this#['protected'+'Method']()\r\n```\r\n\r\nwhich seems to be clear: `this`, `this#`, and `this##` are all treated like objects, and the `.` and `[]` patterns stay the same as they have always been.\r\n\r\nOther objects:\r\n\r\n```js\r\n        other.publicMethod()\r\n        other['public'+'Method']()\r\n        other##.privateMethod()\r\n        other##['private'+'Method']()\r\n        other#.protectedMethod()\r\n        other#['protected'+'Method']()\r\n```\r\n\r\n---\r\n\r\nIs it possible to leave space in the spec for `protected`, in case it is added later?"},"comment":{"url":"https://api.github.com/repos/tc39/proposal-class-fields/issues/comments/450947304","html_url":"https://github.com/tc39/proposal-class-fields/issues/195#issuecomment-450947304","issue_url":"https://api.github.com/repos/tc39/proposal-class-fields/issues/195","id":450947304,"node_id":"MDEyOklzc3VlQ29tbWVudDQ1MDk0NzMwNA==","user":{"login":"ljharb","id":45469,"node_id":"MDQ6VXNlcjQ1NDY5","avatar_url":"https://avatars1.githubusercontent.com/u/45469?v=4","gravatar_id":"","url":"https://api.github.com/users/ljharb","html_url":"https://github.com/ljharb","followers_url":"https://api.github.com/users/ljharb/followers","following_url":"https://api.github.com/users/ljharb/following{/other_user}","gists_url":"https://api.github.com/users/ljharb/gists{/gist_id}","starred_url":"https://api.github.com/users/ljharb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ljharb/subscriptions","organizations_url":"https://api.github.com/users/ljharb/orgs","repos_url":"https://api.github.com/users/ljharb/repos","events_url":"https://api.github.com/users/ljharb/events{/privacy}","received_events_url":"https://api.github.com/users/ljharb/received_events","type":"User","site_admin":false},"created_at":"2019-01-02T18:43:45Z","updated_at":"2019-01-02T18:43:45Z","author_association":"MEMBER","body":"I'm confused; a function has the same behavior no matter where it's invoked from."}}
{"actor":{"display_login":"ljharb"}}