Hello the list,

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;

This makes it clear that foo is a pointer, while bar is not.  This would not be 
so clear in:

Foo* foo, bar;

Our coding conventions, however, prohibit this form of declaration, which 
eliminates the benefit of this.

The rationale for the other form is simpler: the * is an attribute of the type, 
not an attribute of the variable.  This means that it's more consistent.  We'd 
write Foo* everywhere: in variable declaration, return types, arguments, and 
cast expressions.

Thoughts / comments?

David


-- Sent from my Cray X1
_______________________________________________
Etoile-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-discuss

Répondre à