Blocks and nil termination compiler warnings

Hello!

I am starting to really get into Objective-C (looking forward to http://clang.llvm.org/docs/ObjectiveCLiterals.html). I recently ported Underscore.js to Objective-C (https://github.com/kmalakoff/_.m) and had one problem that I couldn’t resolve…how to put up a compiler warning for nil termination on blocks.

Typically, Apple does something like this:

  • (id)arrayWithObjects:(id)firstObj, … NS_REQUIRES_NIL_TERMINATION;

but I need to do something like this:

  • (A*(^)(NSA* array, NSA* array1, … NS_REQUIRES_NIL_TERMINATION ))intersection; // (A is NSMutableArray, NSA is NSArray)

I played around with combinations of attribute((sentinel)) , but nothing produced the correct compiler-time warnings. Is there a way to do this now? Do I need to submit a request to a standards body? Is there already an implementation in the works? Questions, questions.

Also, I am looking for someone to help me optimize and push my port of Underscore.js in Objective.C (I’m nowhere near guru level to do thorough benchmarking and optimizations). If you are interested in pitching in, please let me know!

Kevin

https://github.com/kmalakoff

Sounds like another addition to http://llvm.org/bugs/show_bug.cgi?id=11988 . It looks like we don't support this attribute on types, only on declarations. It makes a lot of sense in my mind to sink the attribute down to the type.

Jordan