22 posts tagged “closures”
2013
What are some JavaScript concepts that took you the longest to understand?
Closures, prototype inheritance, and the “this” keyword.
[... 60 words]2009
10 Uses for Blocks in C/Objective-C. Part of the Cocoa for Scientists series, which is by far the best free Objective-C / Cocoa tutorial I’ve seen anywhere.
And so it goes, around again. Charles Miller on Java, pointing out that if you don’t have closures and first-class functions you end up having to add band-aid solutions and special case syntactic sugar. Python’s lack of multi-line lambdas leads to a similar (though less pronounced) effect.
Mac OS X 10.6 Snow Leopard: the Ars Technica review. The essential review: 23 pages of information-dense but readable goodness. Pretty much everything I know about Mac OS X internals I learnt from reading John Siracusa’s reviews—this one is particularly juice when it gets to Grand Central Dispatch and blocks (aka closures) in C and Objective-C.
Why I don’t love JavaScript’s Module Pattern. Jonathan Snook points out that the module pattern (where private functionality is hidden in a closure and only public methods are revealed to outside scopes) makes code a lot harder to debug. I use the module pattern for pretty much everything, not because I want to keep stuff private but more to avoid any chance of leaking out in to the global namespace. If I need to debug a value I temporarily assign it as a property on the global window object.
why’s potion. why’s latest project is a small, fast language (JIT to x86/x86-64) which seems to take ideas from Ruby, Lua, Python and who knows where else. Everything is based around objects, closures and mixins, with the delightful inclusion of scoped mixins so you can modify an object only within a certain module (hence avoiding Ruby’s action-at-a-distance problems).
2008
Blocks in Objective-C.
Closures are coming soon to Objective-C - interesting syntax, a regular curly brace block preceded by a caret ^{ ... }
.
php: rfc: closures (via) I never thought I’d see the day, but a patch adding closures to PHP has been both proposed and accepted! Looks like a solid implementation—the syntax is similar to JavaScript but makes explicit which variables are to be captured. As with much of PHP, values are copied in to the closure by default but you can use an ampersand to specify JavaScript-style pass-by-reference instead.
Module Pattern Provides No Privacy... at least not in JavaScript(TM) (via) JavaScript variables hidden inside a closure aren’t as hidden as I thought—it turns out you can pass a closure as the second argument to eval (at least in Firefox) and “steal” private variables back out of it.
2007
IE JScript Performance Recommendations Part 3. Once again, Microsoft’s official advice is to avoid closures entirely rather than learn how to use them safely. Sigh.
2006
JavaScript Closures for Dummies. Not quite for Dummies as it talks about C pointers, but a valiant attempt.
Closures And Highly Readable Sequence Sorting Customization. Really neat usage of closures in Python.
Getting Funky With Scopes and Closures. Mark Wubben has some neat tricks up his sleeve.
2005
Leak Free Javascript Closures. This is some pretty brilliant JavaScript voodoo.
Another practical use for JavaScript closures. Create private methods by hiding them in a closure.
2004
Martin Fowler on Closures. They really aren’t that complicated once they’re explained well.
XMLHttpRequest and Javascript Closures. Harry gets intimate with Mozilla’s XMLHttpRequest object.
Javascript Closures. Notes on Closures.
Closures and executing JavaScript on page load. I’ve tried to explain closures on my SitePoint blog, using addLoadEvent() as an example.
Groovy: Closures. I’d nearly written Groovy off as a pointless Jython clone, but it actually has some interesting features.
2003
Closures and continuations
Thanks to Dan Sugalski (designer of Parrot, the next generation Perl VM) I finally understand what continuations and closures actually are. He explains them as part of a comparison between the forthcoming Parrot and two popular virtual machines already in existence: