{"action":"created","issue":{"url":"https://api.github.com/repos/tc39/proposal-decorators/issues/173","repository_url":"https://api.github.com/repos/tc39/proposal-decorators","labels_url":"https://api.github.com/repos/tc39/proposal-decorators/issues/173/labels{/name}","comments_url":"https://api.github.com/repos/tc39/proposal-decorators/issues/173/comments","events_url":"https://api.github.com/repos/tc39/proposal-decorators/issues/173/events","html_url":"https://github.com/tc39/proposal-decorators/issues/173","id":379449655,"node_id":"MDU6SXNzdWUzNzk0NDk2NTU=","number":173,"title":"Homonyms and confused names into descriptors","user":{"login":"pabloalmunia","id":1365303,"node_id":"MDQ6VXNlcjEzNjUzMDM=","avatar_url":"https://avatars3.githubusercontent.com/u/1365303?v=4","gravatar_id":"","url":"https://api.github.com/users/pabloalmunia","html_url":"https://github.com/pabloalmunia","followers_url":"https://api.github.com/users/pabloalmunia/followers","following_url":"https://api.github.com/users/pabloalmunia/following{/other_user}","gists_url":"https://api.github.com/users/pabloalmunia/gists{/gist_id}","starred_url":"https://api.github.com/users/pabloalmunia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pabloalmunia/subscriptions","organizations_url":"https://api.github.com/users/pabloalmunia/orgs","repos_url":"https://api.github.com/users/pabloalmunia/repos","events_url":"https://api.github.com/users/pabloalmunia/events{/privacy}","received_events_url":"https://api.github.com/users/pabloalmunia/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2018-11-10T18:47:50Z","updated_at":"2018-12-16T11:56:29Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"# Homonyms and confused names into descriptors\r\n\r\nWe have found a group of homonyms (same word with different meanings) and other confused names into descriptor objects.\r\n\r\nI have collected some opinions of my team and I include them here with humility. We are not specialists in the definition of programming language standards, we are just a team of enthusiastic programmers of this proposal.\r\n\r\n## `\"method\"`\r\n\r\nCases:\r\n\r\n- `kind: \"method\"` with a method included into `value`.\r\n\r\n- `kind: \"method\"` with a getter / setter included into `descriptor.get` and` descriptor.set`.\r\n\r\nhttps://github.com/tc39/proposal-decorators/issues/162\r\n\r\nAlternatives:\r\n\r\n- `kind: \"property\"` for getter / setter.\r\n- `kind: \"accessor\"` for getter / setter. \r\n\r\nWe vote for `\"property\"` and obtain this values for `kind`: `\"class\"`, `\"method\"`, `\"field\"` and `\"property\"`.\r\n\r\n## `\"descriptor\"`\r\n\r\nCases:\r\n\r\n- *descriptor* or *decotator descriptor* is the generic name used for parameters and returns into decorator functions.\r\n\r\n- `descriptor` is a field of *decorator descriptor* with an `Object.defineProperty()` descriptor.\r\n\r\nhttps://github.com/tc39/proposal-decorators/issues/162#issuecomment-434663810\r\n\r\nAlternatives:\r\n\r\n- remove `descriptor` field and include its member into the first level of *decorator descriptor*. \r\n- change the name to `propertyDescriptor`.\r\n\r\nWe vote for remove `descriptor` and change this:\r\n\r\n```js\r\n{\r\n  kind: \"field\"\r\n  key: \"x\",\r\n  placement: \"own\",\r\n  // property descriptor for Object.defineProperty\r\n  descriptor: { \r\n    configurable: false, \r\n    enumerable: true, \r\n    writable: true \r\n  }\r\n}\r\n```\r\n\r\ninto this:\r\n\r\n```js\r\n{\r\n  kind: \"field\"\r\n  key: \"x\",\r\n  placement: \"own\",\r\n  configurable: false, \r\n  enumerable: true, \r\n  writable: true \r\n}\r\n```\r\n\r\n## `\"initializer\"` vs `\"descriptor.value\"`\r\n\r\nCases:\r\n\r\n- `kind: \"initializer\"` is used for stand-alone initializer.\r\n\r\n- `\"initializer\"` is the field used when `kind: \"initializer\"` and include a function than is callback for side effect.\r\n\r\n- `\"initializer\"` is a field used when `kind: \"field\"` and include a function than return the initial value for this field.\r\n\r\n- The field `\"descriptor.value\"` is used when `kind: \"method\"` and include the function assigned as value.\r\n\r\n\r\nWhen a programmer define a field with a method as value:\r\n\r\n```js\r\nclass K {\r\n  @decorator\r\n  prop = function () {\r\n    return 10;\r\n  }\r\n}\r\n``` \r\n\r\nthe value is included into `initializer`:\r\n\r\n```js\r\n{\r\n  \"kind\": \"field\",\r\n  \"key\": \"prop\",\r\n  \"placement\": \"own\",\r\n  \"descriptor\": {\r\n    \"configurable\": true,\r\n    \"writable\": true,\r\n    \"enumerable\": true\r\n  },\r\n  \"initializer\": function () {\r\n      return function () {\r\n        return 10;\r\n      };\r\n    }\r\n}\r\n```\r\n\r\nAlternatives:\r\n\r\n- use always `initializer` with a funtion than return the initial value (primitive, function, object)\r\n- use `descriptor.value` (or `value`) for initial values and `initializer` only for side effect.\r\n\r\nWe are no sure. We intuit that `initializer` function is important in cases where initial values can not be safely included in `descriptor.value`. Perhaps the solution is use alway `initializer` function and return a function, included when `kind: \"method\"`.\r\n"},"comment":{"url":"https://api.github.com/repos/tc39/proposal-decorators/issues/comments/447637154","html_url":"https://github.com/tc39/proposal-decorators/issues/173#issuecomment-447637154","issue_url":"https://api.github.com/repos/tc39/proposal-decorators/issues/173","id":447637154,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NzYzNzE1NA==","user":{"login":"littledan","id":189835,"node_id":"MDQ6VXNlcjE4OTgzNQ==","avatar_url":"https://avatars3.githubusercontent.com/u/189835?v=4","gravatar_id":"","url":"https://api.github.com/users/littledan","html_url":"https://github.com/littledan","followers_url":"https://api.github.com/users/littledan/followers","following_url":"https://api.github.com/users/littledan/following{/other_user}","gists_url":"https://api.github.com/users/littledan/gists{/gist_id}","starred_url":"https://api.github.com/users/littledan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/littledan/subscriptions","organizations_url":"https://api.github.com/users/littledan/orgs","repos_url":"https://api.github.com/users/littledan/repos","events_url":"https://api.github.com/users/littledan/events{/privacy}","received_events_url":"https://api.github.com/users/littledan/received_events","type":"User","site_admin":false},"created_at":"2018-12-16T11:56:29Z","updated_at":"2018-12-16T11:56:29Z","author_association":"MEMBER","body":"Initializers are optional for fields, but I imagine we could use `initializer: null` if we want to indicate that.\r\n\r\nIn that case, we could just omit the kind then, and use other uniquely named properties for finishers and initializers."}}
{"actor":{"display_login":"littledan"}}