{"action":"created","issue":{"url":"https://api.github.com/repos/justinfagnani/mixwith.js/issues/14","repository_url":"https://api.github.com/repos/justinfagnani/mixwith.js","labels_url":"https://api.github.com/repos/justinfagnani/mixwith.js/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/justinfagnani/mixwith.js/issues/14/comments","events_url":"https://api.github.com/repos/justinfagnani/mixwith.js/issues/14/events","html_url":"https://github.com/justinfagnani/mixwith.js/issues/14","id":165500521,"number":14,"title":"Alternative implementation (multiple inheritance with branching prototype chain)","user":{"login":"trusktr","id":297678,"avatar_url":"https://avatars.githubusercontent.com/u/297678?v=3","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":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-07-14T08:00:52Z","updated_at":"2016-07-14T18:59:15Z","closed_at":null,"body":"Currently, mixwith creates a prototype chain where the mixin prototypes are between the subclass and super class.\r\n\r\nAnother possibility could be to use a Proxy and intercept the property `get` mechanism. The subclass would have a new `prototypes` property which is an array of prototypes (multi-inheritance). The `get` interceptor would loop through the prototypes and lookup the property being requested on each prototype. As for precedence, the proxy would loop from the end of the array and stop at the first prototype chain where the property is found.\r\n\r\nPossible syntax:\r\n\r\n```js\r\nclass ThreeDeeObject extends multiple(Transform, EventEmitter, TreeNode) {}\r\n```\r\n\r\nwhere `multiple` returns a constructor who's prototype is the Proxy created by `multiple`.\r\n\r\nIf we then have\r\n\r\n```js\r\nclass Sphere extends ThreeDeeObject {}\r\n```\r\n\r\nthen the prototype lookup works the same, but when it gets to the prototype of the `multiple` used in `ThreeDeeObject's` definition, then the lookup will use our `get` interceptor and basically lookup will branch into one of the prototypes in the `prototypes` array.\r\n\r\nJust thought I'd jot the idea down here. I'm sure it has pros and cons compared to the mixin approach here."},"comment":{"url":"https://api.github.com/repos/justinfagnani/mixwith.js/issues/comments/232759974","html_url":"https://github.com/justinfagnani/mixwith.js/issues/14#issuecomment-232759974","issue_url":"https://api.github.com/repos/justinfagnani/mixwith.js/issues/14","id":232759974,"user":{"login":"trusktr","id":297678,"avatar_url":"https://avatars.githubusercontent.com/u/297678?v=3","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},"created_at":"2016-07-14T18:59:15Z","updated_at":"2016-07-14T18:59:15Z","body":"To visualize the prototype branching of my example above, it's like this in concept:\r\n\r\n```js\r\n              FooBar\r\n                |\r\n                |\r\n           +----+-----+\r\n           |          |\r\n         Three       One\r\n           |\r\n          Two\r\n```\r\n\r\nBut it's actually like this in implementation, due to the prototype created for the \"multiclass\":\r\n\r\n```js\r\n              FooBar\r\n                |\r\n                |\r\n            MultiClass\r\n                |\r\n                |\r\n           +----+-----+\r\n           |          |\r\n         Three       One\r\n           |\r\n          Two\r\n```\r\n\r\nWhere the MultiClass sets up the branching logic (ideally would be with a `Proxy`)."}}
{"actor":{"display_login":"trusktr"}}