{"action":"created","issue":{"url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/1288","labels_url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/1288/labels{/name}","comments_url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/1288/comments","events_url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/1288/events","html_url":"https://github.com/ceylon/ceylon-spec/issues/1288","id":72790909,"number":1288,"title":"constructors and return","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/clarification","name":"clarification","color":"e102d8"}],"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":56,"closed_issues":1,"state":"open","created_at":"2014-06-06T19:39:15Z","updated_at":"2015-05-12T10:07:40Z","due_on":null,"closed_at":null},"comments":14,"created_at":"2015-05-03T11:13:19Z","updated_at":"2015-05-13T09:01:31Z","closed_at":null,"body":"Here's an interesting case:\r\n\r\n```ceylon\r\n    class Foo {\r\n        shared new () {\r\n            return;\r\n        }\r\n        shared new Baz() {}\r\n        print(\"done\");\r\n    }\r\n```\r\n\r\nCurrently this results in an `unreachable statement` error on the `print()` statement.\r\n\r\nI'm not sure that this is precisely _wrong_, but it's not obviously the only thing that could be correct.\r\n\r\nSo I need to think it through a little further and probably clarify this in the spec."},"comment":{"url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/comments/101580059","html_url":"https://github.com/ceylon/ceylon-spec/issues/1288#issuecomment-101580059","issue_url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/1288","id":101580059,"user":{"login":"luolong","id":133101,"avatar_url":"https://avatars.githubusercontent.com/u/133101?v=3","gravatar_id":"","url":"https://api.github.com/users/luolong","html_url":"https://github.com/luolong","followers_url":"https://api.github.com/users/luolong/followers","following_url":"https://api.github.com/users/luolong/following{/other_user}","gists_url":"https://api.github.com/users/luolong/gists{/gist_id}","starred_url":"https://api.github.com/users/luolong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luolong/subscriptions","organizations_url":"https://api.github.com/users/luolong/orgs","repos_url":"https://api.github.com/users/luolong/repos","events_url":"https://api.github.com/users/luolong/events{/privacy}","received_events_url":"https://api.github.com/users/luolong/received_events","type":"User","site_admin":false},"created_at":"2015-05-13T09:01:31Z","updated_at":"2015-05-13T09:01:31Z","body":"I would vote for this interpretation, yes.\r\n\r\nIt is the most sensible way to interpret return statements given the syntax we have.\r\nAnything else will strike me as as highly surprising behavior.\r\n\r\nConstructor blocks are syntactically very similar to method or getter blocks, so returning from a constructor and exiting the entire initializer is somewhat unexpected.\r\n\r\nAlso, if you really need to exit the whole initializer section, you can have return inside the initializer section.\r\n\r\n`throw` and `assert` are different, as they usually tend to work across multiple call stack frames anyway &mdash; `return` on the other hand usually works within a single call stack frame, which this syntax currently makes us believe.\r\n\r\nOTOH, if we'd be free to change the constructor syntax so that it would more resemble conditional block, I would be okay with returning from the entire intializer block.\r\n\r\nSomething like that maybe:\r\n```ceylon\r\n    class Foo {\r\n        if (shared new Bar()) {\r\n            return;\r\n        }\r\n        print(\"unreachable?\");\r\n        if (shared new Baz() extends Bar()) {\r\n            print(\"unreachable too?\");            \r\n        }\r\n        print(\"unreachable three?\");\r\n    }\r\n```\r\n\r\nor this\r\n```ceylon\r\n    class Foo {\r\n        shared case (new Bar()) {\r\n            return;\r\n        }\r\n        print(\"unreachable?\");\r\n        shared case (new Baz() extends Bar()) {\r\n            print(\"unreachable too?\");            \r\n        }\r\n        print(\"unreachable three?\");\r\n    }\r\n```"}}