[PATCH] Allow trailing comma in Objective-C protocol lists.

Dmitri Gribenko gribozavr at gmail.com
Sat Apr 4 23:36:40 PDT 2015


+Doug

On Mon, Mar 30, 2015 at 11:46 PM, Grant Paul <grp at fb.com> wrote:
> Hi,
>
> This patch allows trailing commas in protocol lists. This is useful
> when conditionally conforming to protocols. For example:
>
>     @inteface MyView : UIView <
>       UITableViewDelegate,
>     #ifdef IN_APP_EXTENSION
>       UIGestureRecognizerDelegate,
>     #endif
>     #ifdef OPTIONAL_FEATURE
>       UITextFieldDelegate,
>     #endif
>     >
>
>     @end
>
> Without this patch, there's no clean way to write that because the
> protocol list is not allowed to have a trailing comma. (You could use
> JavaScript-style leading commas, but that’s not common in C-based
> languages.) With this patch, the trailing comma is simply ignored. It’s
> similar to how it’s ignored in Objective-C array and dictionary literals.

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/




More information about the cfe-commits mailing list