{"action":"created","issue":{"url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/1416","labels_url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/1416/labels{/name}","comments_url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/1416/comments","events_url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/1416/events","html_url":"https://github.com/ceylon/ceylon-spec/issues/1416","id":104763431,"number":1416,"title":"Declare superinterfaces of existing types","user":{"login":"Zambonifofex","id":12286722,"avatar_url":"https://avatars.githubusercontent.com/u/12286722?v=3","gravatar_id":"","url":"https://api.github.com/users/Zambonifofex","html_url":"https://github.com/Zambonifofex","followers_url":"https://api.github.com/users/Zambonifofex/followers","following_url":"https://api.github.com/users/Zambonifofex/following{/other_user}","gists_url":"https://api.github.com/users/Zambonifofex/gists{/gist_id}","starred_url":"https://api.github.com/users/Zambonifofex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zambonifofex/subscriptions","organizations_url":"https://api.github.com/users/Zambonifofex/orgs","repos_url":"https://api.github.com/users/Zambonifofex/repos","events_url":"https://api.github.com/users/Zambonifofex/events{/privacy}","received_events_url":"https://api.github.com/users/Zambonifofex/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-03T19:20:02Z","updated_at":"2015-09-03T19:25:12Z","closed_at":null,"body":"I think we should be able to declare supertypes of existing types. Declaring superclasses would be fragile, but I think declaring superinterfaces could be pretty cool. Let's suppose I want the `Object` class to have one more member. `html`, for example, which returns a DOM representation of the object. I could do the following:\r\n```Ceylon\r\nshared interface DOMRepresentable\r\nabstracts Object\r\n{\r\n\tshared default DOMNode html\r\n\t{\r\n\t\tdynamic\r\n\t\t{\r\n\t\t\treturn(document.createTextNode(this.string));\r\n\t\t}\r\n\t}\r\n}\r\n```\r\n\r\nWhenever someone imports our module, and our `DOMRepresentable` interface, they see that `Object` contains a `html` attribute, and them can override it in their subclasses.\r\n\r\nThis interfaces have to provide an implementation for all their members.\r\n\r\nThis could be a neat way to add members to types that aren't represented by classes/interfaces.\r\n\r\n```Ceylon\r\nshared interface Foo\r\nabstracts Iterable&Bar\r\n{\r\n\tshared void foo() => baz();\r\n}\r\n\r\nvoid test()\r\n{\r\n\tIterable iterable => \"Hello\";\r\n\tBar bar => Bar();\r\n\tIterable&Bar ibar => getIterableBar();\r\n\t\r\n\t// iterable.baz(); // error\r\n\t// bar.baz(); // error\r\n\tibar.baz(); // ok\r\n}\r\n```\r\n\r\nI'm unsure whether there should be a special `super` annotation for those interfaces, nor if they should be implementable, or usable as types. I certainly don't want supertypes of `Anything`, specially populated ones..."},"comment":{"url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/comments/137548072","html_url":"https://github.com/ceylon/ceylon-spec/issues/1416#issuecomment-137548072","issue_url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/1416","id":137548072,"user":{"login":"lucaswerkmeister","id":2346599,"avatar_url":"https://avatars.githubusercontent.com/u/2346599?v=3","gravatar_id":"","url":"https://api.github.com/users/lucaswerkmeister","html_url":"https://github.com/lucaswerkmeister","followers_url":"https://api.github.com/users/lucaswerkmeister/followers","following_url":"https://api.github.com/users/lucaswerkmeister/following{/other_user}","gists_url":"https://api.github.com/users/lucaswerkmeister/gists{/gist_id}","starred_url":"https://api.github.com/users/lucaswerkmeister/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucaswerkmeister/subscriptions","organizations_url":"https://api.github.com/users/lucaswerkmeister/orgs","repos_url":"https://api.github.com/users/lucaswerkmeister/repos","events_url":"https://api.github.com/users/lucaswerkmeister/events{/privacy}","received_events_url":"https://api.github.com/users/lucaswerkmeister/received_events","type":"User","site_admin":false},"created_at":"2015-09-03T19:25:12Z","updated_at":"2015-09-03T19:25:12Z","body":"I think extension methods, as proposed by #1146, are a *much* better solution to this problem."}}