{"action":"created","issue":{"url":"https://api.github.com/repos/ceylon/ceylon/issues/6406","repository_url":"https://api.github.com/repos/ceylon/ceylon","labels_url":"https://api.github.com/repos/ceylon/ceylon/issues/6406/labels{/name}","comments_url":"https://api.github.com/repos/ceylon/ceylon/issues/6406/comments","events_url":"https://api.github.com/repos/ceylon/ceylon/issues/6406/events","html_url":"https://github.com/ceylon/ceylon/issues/6406","id":168507006,"number":6406,"title":"one-shot Iterables","user":{"login":"dlkw","id":15879995,"avatar_url":"https://avatars.githubusercontent.com/u/15879995?v=3","gravatar_id":"","url":"https://api.github.com/users/dlkw","html_url":"https://github.com/dlkw","followers_url":"https://api.github.com/users/dlkw/followers","following_url":"https://api.github.com/users/dlkw/following{/other_user}","gists_url":"https://api.github.com/users/dlkw/gists{/gist_id}","starred_url":"https://api.github.com/users/dlkw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlkw/subscriptions","organizations_url":"https://api.github.com/users/dlkw/orgs","repos_url":"https://api.github.com/users/dlkw/repos","events_url":"https://api.github.com/users/dlkw/events{/privacy}","received_events_url":"https://api.github.com/users/dlkw/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ceylon/ceylon/labels/c-basic%20language","name":"c-basic language","color":"02d7e1"},{"url":"https://api.github.com/repos/ceylon/ceylon/labels/t-discussion","name":"t-discussion","color":"006b75"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":24,"created_at":"2016-07-31T07:56:55Z","updated_at":"2016-07-31T18:54:13Z","closed_at":"2016-07-31T18:20:35Z","body":"The \"one-shot Iterable\" vs. \"reiterable Iterable\", which already caused some discussion in the [XML parser thread on the users mailing list](https://groups.google.com/forum/#!topic/ceylon-users/VFZGRy34Tsg) and also for example in https://github.com/ceylon/ceylon-sdk/issues/593#issuecomment-236379752, can perhaps be accomodated by introducing interfaces\r\n\r\n```ceylon\r\n\"iterable structure that can be iterated at least once\"\r\nshared interface OneShotIterable<out Element> {\r\n    \"returns always the one and same iterator\"\r\n    shared Iterator<Element> sameIterator();\r\n}\r\n\r\n\"iterable structure that can be iterated multiple times\"\r\nshared interface ReIterable<out Element>\r\n        satisfies OneShotIterable<Element> {\r\n    \"the first call returns sameIterator(), the following calls return different iterators.\"\r\n    shared Iterator<Element> newIterator();\r\n}\r\n```\r\n\r\nThe name of the second interface and its method can be adapted to match the existing Iterable.\r\nI admit this is a rather big intrusion into the existing ceylon.language package, but maybe it can be developed into a good solution. Right now, the type system cannot distinguish between single shot and reiterable Iterables."},"comment":{"url":"https://api.github.com/repos/ceylon/ceylon/issues/comments/236449590","html_url":"https://github.com/ceylon/ceylon/issues/6406#issuecomment-236449590","issue_url":"https://api.github.com/repos/ceylon/ceylon/issues/6406","id":236449590,"user":{"login":"quintesse","id":778793,"avatar_url":"https://avatars.githubusercontent.com/u/778793?v=3","gravatar_id":"","url":"https://api.github.com/users/quintesse","html_url":"https://github.com/quintesse","followers_url":"https://api.github.com/users/quintesse/followers","following_url":"https://api.github.com/users/quintesse/following{/other_user}","gists_url":"https://api.github.com/users/quintesse/gists{/gist_id}","starred_url":"https://api.github.com/users/quintesse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quintesse/subscriptions","organizations_url":"https://api.github.com/users/quintesse/orgs","repos_url":"https://api.github.com/users/quintesse/repos","events_url":"https://api.github.com/users/quintesse/events{/privacy}","received_events_url":"https://api.github.com/users/quintesse/received_events","type":"User","site_admin":false},"created_at":"2016-07-31T18:54:13Z","updated_at":"2016-07-31T18:54:13Z","body":"> OTOH, if the XML parser accepts {Byte*}\r\n\r\nBut that's the whole point of this discussion, if you just have an Iterable you're basically dealing with the lowest level API possible and you can't make use of *any* of the nice methods in Iterable. So you can't filter, you can't map, you can't do anything except get the next value. You might as well start programming assembly.\r\n"}}
{"actor":{"display_login":"quintesse"}}