Speed of Light

A Suggestion to Improve Objective-C's new Autoboxing support

In the 2012 edition of the Clang compiler, Objective-C gained support for some new language features like NSArray and NSDictionary literals, @[] and @{} respectively. It also gained support for turning numbers into NSNumber by wrapping the number literal (or expression) with @(), or in some cases simply prefixing with with @.

So now to make an NSArray of NSNumbers we can do the following:

NSArray *numbers = @[@1, @2, @(1+2), @YES];

That's a nice improvement, but it's still completely ridiculous to type. Instead, I suggest allowing the following:

NSArray *numbers = @[1, 2, 1+2, YES];

Drop the autoboxing typing inside the array. The compiler should already know it's an Objective-C array because it's @[], so why not just automatically wrap up any scalars as objects for us?