Simon Willison’s Weblog

Subscribe
Atom feed for closures

8 items tagged “closures”

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.

# 16th November 2009, 2:27 pm / cocoa, osx, objectivec, blocks, closures, science

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.

# 1st September 2009, 7:05 pm / objectivec, c, closures, blocks, osx, apple, john-siracusa, grandcentraldispatch, snowleopard

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.

# 30th April 2009, 7:59 pm / javascript, modulepattern, jonathan-snook, closures, debugging

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).

# 8th January 2009, 6:37 pm / ruby, whytheluckystiff, potion, programming, languages, jit, lua, mixins, closures

2008

Blocks in Objective-C. Closures are coming soon to Objective-C - interesting syntax, a regular curly brace block preceded by a caret ^{ ... }.

# 29th December 2008, 7:38 pm / objectivec, closures, programming, blocks, syntax

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.

# 19th July 2008, 10:58 pm / closures, php, functional-programming, javascript

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.

# 27th June 2008, 7:01 pm / closures, javascript, firefox, modulepattern, pete-michaux

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.

# 9th January 2007, 11:48 am / microsoft, ie, closures, javascript