clang: Add auto (or @auto) to Objective-C
| Originator: | sdfisher | ||
| Number: | rdar://11819919 | Date Originated: | 06-Jul-2012 11:22 AM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | |
| Classification: | Feature Request | Reproducible: |
I see a small but significant minority of developers using Objective-C++ instead of Objective-C just so they can use C++11's auto keyword. Please add auto (or @auto) to Objective-C. Syntactically it would look like id, but allow property access using dot syntax and type checking. Consider: id request = [NSHTTPURLRequest requestWith...]; id headers = [request allHTTPHeaderFields]; // dot syntax not allowed [self doSomethingWithArray: headers]; // no compiler warning vs. @auto request = [NSHTTPURLRequest requestWith...]; @auto headers = request.allHTTPHeaderFields; // imagine this was actually a property :) [self doSomethingWithArray: headers]; // compiler warning
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Possible workaround
Can't you accomplish basically the same thing by creating a read-only property for the method?
Duped as rdar://11820613