{"issue":{"state":"open","created_at":"2011-12-02T05:52:54Z","updated_at":"2011-12-02T17:08:23Z","comments":24,"user":{"gravatar_id":"8672f1c3b11cc7390ec341ac25d7e88e","id":579974,"url":"https://api.github.com/users/gavinking","avatar_url":"https://secure.gravatar.com/avatar/8672f1c3b11cc7390ec341ac25d7e88e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"gavinking"},"body":"So, it appears to me that we've moved away from the idea of Smalltalk-style arguments for invocation of higher-order functions, and that everyone seems to want a much more conventional syntax for anonymous functions inside positional argument lists (see #54). I can live with that. But if that's the case, then I'm going to have to insist that we *at least* need a specialized syntax for comprehensions. There's many many [possible variations](http://en.wikipedia.org/wiki/List_comprehension) of this syntax, but the two possibilities that I think would make most sense are the following:\r\n\r\n    { (x**2+y**2)**0.5: x in 0..100 && x%10==0, y in -10..+10 && y%2==0 }\r\n\r\nor\r\n\r\n    { (x**2+y**2)**0.5: x in 0..100, x%10==0; y in -10..+10, y%2==0 }\r\n\r\nI don't have an especially strong preference between these two options. I think the first is more consistent with the rest of our notation, and the second is perhaps slightly easier on the eyes. The second option is also a bit better from a grammar point of view.\r\n\r\nOf course, there is also an argument for something like the following syntax:\r\n\r\n    { (x**2+y**2)**0.5 for (x in 0..100) if (x%10==0) for (y in -10..+10) if (y%2==0) }\r\n\r\nBut in this case, I don't think the extra verbosity contributes to readability.\r\n\r\nNote that since this is probably something I can desugar in the frontend, we could probably have this feature almost immediately.\r\n\r\nThoughts?\r\n\r\n**UPDATE:**\r\n\r\nNote that this syntax would be allowed to appear in two places:\r\n\r\n1. where sequence enumerations appear, which would instantiate an `ArraySequence`, and\r\n2. in place of a named argument list, producing an `Iterable` (or perhaps some kind of lazy sequence).\r\n\r\nSo you would be able to write:\r\n\r\n    HashMap { p.name->p.address: p in people }","assignee":null,"id":2424249,"number":82,"labels":[{"color":"0b02e1","name":"request for feedback","url":"https://api.github.com/repos/ceylon/ceylon-spec/labels/request+for+feedback"}],"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"title":"Sequence comprehensions","closed_at":null,"html_url":"https://github.com/ceylon/ceylon-spec/issues/82","url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/82","milestone":null},"action":"created","comment":{"created_at":"2011-12-02T17:08:23Z","updated_at":"2011-12-02T17:08:23Z","user":{"gravatar_id":"8672f1c3b11cc7390ec341ac25d7e88e","id":579974,"url":"https://api.github.com/users/gavinking","avatar_url":"https://secure.gravatar.com/avatar/8672f1c3b11cc7390ec341ac25d7e88e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"gavinking"},"body":"@FroMage\r\n\r\n> It's not obvious to me that the second syntax would pass every param in the varargs rather than a list of values as the first element of the vararg array.\r\n\r\nHow about if it were:\r\n\r\n    print(for (w in words) w);\r\n","id":2992785,"url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/comments/2992785"}}