July 2010

Callable

A couple of projects required that I get fairly serious about working with Javascript. And like so many I found a nice little language muddied by the vagaries of DOM implementations and some unfortunate syntax edge cases. The flexibility of having functions as a first class entity was something I'd been aware of in the abstract, but working in Javascript really drove it home. About the same time I had to do real work with Objective-C and Cocoa, both on Mac and iPhone.
The compositional flexibility of Javascript and Cocoa was liberating and disconcerting. After all there's real utility in the rigidity of C++'s type system; the compiler becomes an ally in the exploration and definition of a problem's characteristics. But those Javascript and Objective-C callbacks are themselves compelling.
My response to that tension is ZCallable. Certainly not the first generic callback mechanism, but one I've found comprehensible and usable. The basic template suite: ZCallable_Block, ZCallable_Function, ZCallable_ObjC and ZCallable_PMF encapsulate the several forms of function in C++ and Objective-C++. ZCallable_Bind provides closure-like facilties, and other parts of the suite provide mechanisms for combining and parameterizing callables.

Projects by Category

Recent Projects

Project Archives