Le 12 juil. 2011 à 15:50, David Chisnall a écrit : > On 12 Jul 2011, at 14:37, Quentin Mathé wrote: > >>>> Nicolas suggested we use Foo* rather than Foo * precisely for this reason. >>>> I rather like the idea, but it decreases readability too much imo. >>>> Especially arguments looks less readable in methods declarations. >>>> >>>> - (NSArray*) emailsForMailbox: (CDCMailbox*)theMailbox; >>>> >>>> vs >>>> >>>> - (NSArray *) emailsForMailbox: (CDCMailbox *)theMailbox; >>> >>> Do we use the latter form? >> >> Yes, this except is taken from the guidelines. > > I just read that section, and I disagree with it entirely.
Hm, you agreed to these guidelines few years ago, so I'm a bit suprised you put it that way now. There are points that should be changed, but 'entirely' is a bit vague or radical imo. > It also says this: > >> Finally always include return type, even if it's id. > > I dislike this (and don't use it), because these are NOT type declarations, > they are cast expressions. This is why their syntax is the cast expression > syntax, not the type declaration syntax. Requiring redundant casts is a bad > idea. > > The examples are also really bad because we're putting the cast expression on > the argument and the return in different places. > > Objective-C parameter and return types are fundamentally different from C > function types. They are not saying 'this value is this type', they are > saying 'this value is something that you can safely cast to this type'. > That's an important distinction at the language level, and should be > reflected in the style. This is why I use this form: > > - (NSArray*)emailsForInbox: (CDCMailbox*)theMailbox; > > In a C function, this would be written as: > > NSArray* emailsForInbox(CDCMailbox* theMailbox); > > In both cases, the intent and the underlying semantics are clearly stated. For the return type as a cast, that's something we discussed several times. Although I'm not convinced by this change, I don't mind to switch. It isn't too costly. So - (NSArray *)bla instead of - (NSArray *) bla However I'm strongly against changing how pointers are declared in arguments and variables. If at some point, we get a very good tool to handle reformatting Objective-C, we might want to rediscuss it though. Cheers, Quentin. _______________________________________________ Etoile-discuss mailing list [email protected] https://mail.gna.org/listinfo/etoile-discuss
