Thursday, November 12, 2009

Generics in Objective-C

Jens Ayton proposes that adding generics to Objective-C would allow for better static analysis with no changes at runtime or to existing code. Jesper concurs. This seems like a reasonable idea, although I’m not sure it’s worth the hassle and visual clutter. I don’t think improper typing is a major source of bugs.

1 Comment RSS · Twitter

I don't think improper typing is a major source of bugs either. It's a major source of *unconfidence*. Even if you jot it down in documentation, clang isn't a big fan of R-ing TFM. And I'll be the first to agree that [:self] is dog-ugly, but the regulatory C superset noose constricts the number of syntaxes that are available.

I don't buy the argument that more types are automatically better, and it's famously hard to get generics flexible enough to do anything well. But that's why Ayton confines the proposal to just the cases where a) generics do work, and well, and b) they actually solve a real, long-time problem in Objective-C which is that of discerning the type of convenience constructors when inherited. They shouldn't add generics to Objective-C because they're generics, but because in the form proposed, they are useful.

Leave a Comment