{"id":156,"date":"2006-06-05T00:37:00","date_gmt":"2006-06-05T08:37:00","guid":{"rendered":"http:\/\/eschatologist.net\/blog\/?p=156"},"modified":"2009-02-03T20:58:03","modified_gmt":"2009-02-04T04:58:03","slug":"programming-language-terminology-lesson-closures","status":"publish","type":"post","link":"https:\/\/eschatologist.net\/blog\/?p=156","title":{"rendered":"Programming language terminology lesson: Closures"},"content":{"rendered":"<p>In reading <cite>Beyond Java<\/cite> by <a href=\"http:\/\/blog.rapidred.com\/\">Bruce Tate<\/a>, I saw the following:<\/p>\n<blockquote><p>Java&#8217;s syntax lacks features like closures and <em>code blocks<\/em> (which let you pass a block of code as an argument).<\/p><\/blockquote>\n<p>  <strong>Argh!<\/strong><\/p>\n<p>In the vast majority of languages that support them, a block <em>is<\/em> a closure!  Blocks, closures, lambdas \u00e2\u20ac\u201d they&#8217;re all just different words for the same thing!  A closure is just a piece of code that carries around (&#8220;closes over&#8221;) definitions from the environment in it was defined, and can be executed later using those definitions, possibly taking some arguments as input as well.<\/p>\n<p>The terminology distinction between blocks and closures probably comes from the days when Smalltalk blocks <em>weren&#8217;t<\/em> closures.  That is, they would reference the environment in which they were <em>executed<\/em> rather than the environment in which they were <em>defined<\/em>.  However, since at least the early 1990s, I believe all major Smalltalk environments have switched to representing blocks as closures.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In reading Beyond Java by Bruce Tate, I saw the following: Java&#8217;s syntax lacks features like closures and code blocks (which let you pass a block of code as an argument). Argh! In the vast majority of languages that support them, a block is a closure! Blocks, closures, lambdas \u00e2\u20ac\u201d they&#8217;re all just different words&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[3],"tags":[40,113,125,37,114,38],"class_list":["post-156","post","type-post","status-publish","format-standard","hentry","category-technology","tag-lisp","tag-programming-languages","tag-python","tag-ruby","tag-scheme","tag-smalltalk"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p74loH-2w","_links":{"self":[{"href":"https:\/\/eschatologist.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/156","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eschatologist.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eschatologist.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eschatologist.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/eschatologist.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=156"}],"version-history":[{"count":1,"href":"https:\/\/eschatologist.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/156\/revisions"}],"predecessor-version":[{"id":157,"href":"https:\/\/eschatologist.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/156\/revisions\/157"}],"wp:attachment":[{"href":"https:\/\/eschatologist.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eschatologist.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eschatologist.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}