{"action":"created","issue":{"url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/1125","labels_url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/1125/labels{/name}","comments_url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/1125/comments","events_url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/1125/events","html_url":"https://github.com/ceylon/ceylon-spec/issues/1125","id":47230570,"number":1125,"title":"reified constructors","user":{"login":"gavinking","id":579974,"avatar_url":"https://avatars.githubusercontent.com/u/579974?v=3","gravatar_id":"","url":"https://api.github.com/users/gavinking","html_url":"https://github.com/gavinking","followers_url":"https://api.github.com/users/gavinking/followers","following_url":"https://api.github.com/users/gavinking/following{/other_user}","gists_url":"https://api.github.com/users/gavinking/gists{/gist_id}","starred_url":"https://api.github.com/users/gavinking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gavinking/subscriptions","organizations_url":"https://api.github.com/users/gavinking/orgs","repos_url":"https://api.github.com/users/gavinking/repos","events_url":"https://api.github.com/users/gavinking/events{/privacy}","received_events_url":"https://api.github.com/users/gavinking/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ceylon/ceylon-spec/labels/basic%20language","name":"basic language","color":"AA1155"},{"url":"https://api.github.com/repos/ceylon/ceylon-spec/labels/request%20for%20feedback","name":"request for feedback","color":"0b02e1"}],"state":"open","locked":false,"assignee":{"login":"gavinking","id":579974,"avatar_url":"https://avatars.githubusercontent.com/u/579974?v=3","gravatar_id":"","url":"https://api.github.com/users/gavinking","html_url":"https://github.com/gavinking","followers_url":"https://api.github.com/users/gavinking/followers","following_url":"https://api.github.com/users/gavinking/following{/other_user}","gists_url":"https://api.github.com/users/gavinking/gists{/gist_id}","starred_url":"https://api.github.com/users/gavinking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gavinking/subscriptions","organizations_url":"https://api.github.com/users/gavinking/orgs","repos_url":"https://api.github.com/users/gavinking/repos","events_url":"https://api.github.com/users/gavinking/events{/privacy}","received_events_url":"https://api.github.com/users/gavinking/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/ceylon/ceylon-spec/milestones/10","html_url":"https://github.com/ceylon/ceylon-spec/milestones/1.3","labels_url":"https://api.github.com/repos/ceylon/ceylon-spec/milestones/10/labels","id":683676,"number":10,"title":"1.3","description":"","creator":{"login":"gavinking","id":579974,"avatar_url":"https://avatars.githubusercontent.com/u/579974?v=3","gravatar_id":"","url":"https://api.github.com/users/gavinking","html_url":"https://github.com/gavinking","followers_url":"https://api.github.com/users/gavinking/followers","following_url":"https://api.github.com/users/gavinking/following{/other_user}","gists_url":"https://api.github.com/users/gavinking/gists{/gist_id}","starred_url":"https://api.github.com/users/gavinking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gavinking/subscriptions","organizations_url":"https://api.github.com/users/gavinking/orgs","repos_url":"https://api.github.com/users/gavinking/repos","events_url":"https://api.github.com/users/gavinking/events{/privacy}","received_events_url":"https://api.github.com/users/gavinking/received_events","type":"User","site_admin":false},"open_issues":60,"closed_issues":1,"state":"open","created_at":"2014-06-06T19:39:15Z","updated_at":"2015-03-11T18:35:29Z","due_on":null,"closed_at":null},"comments":28,"created_at":"2014-10-30T03:42:30Z","updated_at":"2015-03-11T19:39:31Z","closed_at":null,"body":"While working on #796, it became clear that the simplest way to implement constructors in the typechecker was to treat a constructor as a sort of subtype of the class. I then have hacks to hide this from the actual programmer though it still kinda leaks through a bit in the IDE in the same way that `object` classes sometimes leak through.\r\n\r\nThis got me asking whether we should just embrace this and say that a constructor is a type! We've already proposed in #796 that we have singleton constructors that give as a streamlined syntax for Java-style enums, but if we also reified constructors, then this would be a bit more powerful. Of course we would have to somehow tag instances of a class with the constructor that produced the instance but that doesn't sound very hard. Then you could write stuff like:\r\n\r\n    class Point {\r\n        ...\r\n        shared case origin { ... }\r\n        shared new Polar(Float x, Float y) { ... }\r\n        shared new Cartesian(Float r, Float theta) { ... }\r\n    }\r\n\r\n    ...\r\n\r\n    switch (point)\r\n    case (is Point.Polar) { ... }\r\n    case (is Point.Cartesian) { ... }\r\n    case (Point.origin) { ... }\r\n\r\nOr whatever. Constructor refs like `Point.Polar` and `Point.Cartesian` would be legitimate types within the language.\r\n\r\nCounterintuitively, this would _simplify_ the typechecker.\r\n\r\nThoughts?"},"comment":{"url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/comments/78353749","html_url":"https://github.com/ceylon/ceylon-spec/issues/1125#issuecomment-78353749","issue_url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/1125","id":78353749,"user":{"login":"RossTate","id":1139675,"avatar_url":"https://avatars.githubusercontent.com/u/1139675?v=3","gravatar_id":"","url":"https://api.github.com/users/RossTate","html_url":"https://github.com/RossTate","followers_url":"https://api.github.com/users/RossTate/followers","following_url":"https://api.github.com/users/RossTate/following{/other_user}","gists_url":"https://api.github.com/users/RossTate/gists{/gist_id}","starred_url":"https://api.github.com/users/RossTate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RossTate/subscriptions","organizations_url":"https://api.github.com/users/RossTate/orgs","repos_url":"https://api.github.com/users/RossTate/repos","events_url":"https://api.github.com/users/RossTate/events{/privacy}","received_events_url":"https://api.github.com/users/RossTate/received_events","type":"User","site_admin":false},"created_at":"2015-03-11T19:39:31Z","updated_at":"2015-03-11T19:39:31Z","body":"Going back to the original topic, if you're matching on which constructor was used to create the instance, aren't you just manually implementing dynamic dispatch?"}}