tag:blogger.com,1999:blog-7290642316743338665.post7926025574899642244..comments2023-09-20T05:23:44.886-05:00Comments on behind the times: Continuations Passing Style (poorly) Explained II: Java 7 BGGA Closures PrototypeHamlet D'Arcyhttp://www.blogger.com/profile/04008870357169725586noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-7290642316743338665.post-84528507937364122662008-02-12T19:21:00.000-06:002008-02-12T19:21:00.000-06:00Return doesn't do what you think inside a BGGA clo...Return doesn't do what you think inside a BGGA closure, it is one of the things I think will cause huge grief, see:<BR/><BR/>http://www.artima.com/weblogs/viewpost.jsp?thread=202004<BR/><BR/>Particularly section 7.<BR/><BR/>and also:<BR/><BR/>http://www.artima.com/weblogs/viewpost.jsp?thread=220920<BR/><BR/>I think (I haven't checked) your code should be (I had to swop angle brackets for [] and indent using _ :-( ):<BR/><BR/>List[Integer] evens(final List[Integer] numbers) {<BR/>__return findFirst(numbers, { Integer first, List[Integer] rest =><BR/>____first == null ?<BR/>______Collections.emptyList() //no more elements<BR/>______:<BR/>______List[Integer] result = new ArrayList[Integer]();<BR/>______if (first % 2 == 0) { result.add(first); } //match!<BR/>______result.addAll(evens(rest));<BR/>______result // DO NOT put a semicolon here!!!!!!<BR/>__} );<BR/>}<BR/><BR/>To me this looks harder than at present! So why bother?hlovatthttps://www.blogger.com/profile/07048859648718746436noreply@blogger.comtag:blogger.com,1999:blog-7290642316743338665.post-65770894475305080002008-02-12T07:13:00.000-06:002008-02-12T07:13:00.000-06:00Update: Like many people, I've been grappling with...Update: Like many people, I've been grappling with trying to understand continuations. In these posts, I tried to reduce continuations to their absolute essence. But in doing so, I may have missed the mark widely. I might have reduced and twisted them to the point where they aren't continuations at all, but something else entirely. As the joke goes, "Why isn't an elephant small, round, and white? Because then it would be an aspirin." Maybe all that is left of this post is a strange clever trick/ugly hack. Sorry if I've added to your confusion and misinformation... it was fun to write.Hamlet D'Arcyhttps://www.blogger.com/profile/04008870357169725586noreply@blogger.com