Hey David,

Le 8 juil. 2011 à 19:14, David Chisnall a écrit :

> There are two ways of writing pointer declarations:
> 
> Foo *foo;
> Foo* foo;
> 
> Our coding conventions currently recommend the former, but I have recently 
> been convinced that the latter is preferable.
> 
> The rationale that we have for preferring the former is that it avoids 
> ambiguity in cases like this:
> 
> Foo *foo, bar;

It's was more about readability. A space before the * makes it stands out in a 
more clear way.
We disallow multiple multiple variable declarations on a single line, so the 
example doesn't really hold.

> The rationale for the other form is simpler: the * is an attribute of the 
> type, not an attribute of the variable.  

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;

It's subtle I admit :-)

> This means that it's more consistent.  We'd write Foo* everywhere: in 
> variable declaration, return types, arguments, and cast expressions.

Hmm, we already write Foo * in variable declarations, arguments and return 
types as the coding guidelines require it. For cast expression, I use the same 
personally.

The most problematic point behind your suggestion is that it would imply that 
the code would become really inconsistent everywhere. Given the coding 
guidelines are already applied pretty loosely throughout our codebase, the 
situation would become even worse.
This puts aside we should revise some more minor points (e.g. ChangeLog, 
Project Layout) in our coding guidelines I agree.

Cheers,
Quentin.
_______________________________________________
Etoile-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-discuss

Répondre à