tag:blogger.com,1999:blog-8055871.post3684618471889767702..comments2024-03-20T02:54:54.722-04:00Comments on Blatherberg: Story Time with Google Collectionskonberghttp://www.blogger.com/profile/04616226121996611123noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-8055871.post-82431966536006115262010-01-06T04:02:16.381-05:002010-01-06T04:02:16.381-05:00I know I'm way late to this conversation, but....I know I'm way late to this conversation, but... technically, it's not closures you need. The applied function doesn't need access to any elements outside the function, which is the binding a closure provides. You just need a function declaration syntax that doesn't suck. Something like "lambda x: return x.asY()" in Python, or "function(x) { return x.asY(); }" in Javascript. Being dynamically typed seems to lend a lot of brevity here.shadowmatterhttps://www.blogger.com/profile/01123264110675539010noreply@blogger.comtag:blogger.com,1999:blog-8055871.post-11369438773296857592009-10-20T02:59:04.476-04:002009-10-20T02:59:04.476-04:00/me goes off to cry about the lack of closures in .../me goes off to cry about the lack of closures in Java....Brianhttps://www.blogger.com/profile/03246605570740434443noreply@blogger.comtag:blogger.com,1999:blog-8055871.post-60673948204701292272009-10-14T10:16:38.744-04:002009-10-14T10:16:38.744-04:00If the closure syntax was available then the reada...If the closure syntax was available then the readability improvement would surely be worth the potentially small performance penalty, and the story wouldn't be as confusing.konberghttps://www.blogger.com/profile/04616226121996611123noreply@blogger.comtag:blogger.com,1999:blog-8055871.post-52866968473089923532009-10-13T02:40:52.888-04:002009-10-13T02:40:52.888-04:00I use Array.map all the time in JavaScript. Howeve...I use Array.map all the time in JavaScript. However, JavaScript has closures (and function expressions) so you can take the declarative/functional approach without it obscuring your intent as much.<br /><br />In this case: `array.map(function(s) s.asY())`.<br /><br />Of course, this creates a copy of the array rather than a view. But it's quite succinct and easy, if you don't care about the difference in performance.Mike Bostockhttps://www.blogger.com/profile/13533475496966995398noreply@blogger.com