[c++] Why do you write "int *number" instead of "int* number"?

Started by
44 comments, last by visitor 14 years, 5 months ago
Quote:Original post by DevFred
Quote:Bjarne once said
Quite often, there's a problem. People don't really want to argue about these big things. You come with something like [...] how to do a type system for templates, we don't get a discussion about that.
Now if you discuss about how to write a for loop, you get a really splendid discussion.
If you start arguing about wether you should have a space in between the int and the star in a pointer-to-int, you get a REALLY furious discussion.
People actually LOVE discussing things that don't matter, because it's so easy to have an opinion about those things.


Heh. In that respect, don't forget the bikeshed:

Quote:Parkinson dramatizes his Law of Triviality with a committee's deliberations on a nuclear power plant, contrasting it to deliberation on a bicycle shed. A nuclear reactor is used as example because it is so vastly expensive and complicated that average people cannot understand it, so they assume that those working on it understand it. Even those with strong opinions often withhold them for fear of being shown to be insufficiently informed. On the other hand, everyone understands a bicycle shed (or thinks he or she does), so building one can result in endless discussions because everyone involved wants to add his or her touch and show that they have contributed. While discussing the bikeshed, debate emerges over whether the best choice of roofing is aluminum, asbestos, or galvanized iron, rather than whether the shed is a good idea or not.
Advertisement
Quote:Original post by Wan
Quote:Original post by dmatter
I like my whitespace so I prefer to have those sigils floating in it:

int * a;
int & b;

Eew, I hate that. I always get confused for a moment when I see that in code.
Please don't tell me you're declaring your pointers to pointers like this: int * * a; [wink]
I suppose if I was feeling masochistic enough to use pointers-to-pointers then I'd write them like this: int ** a;

More frequently I want a reference to a pointer for low-level code that has to talk to a C library or something: void *& data;
I think it might be concluded that the only things not entirely OK stylewise in C++ are declarations like:

int a, *p;int *p, a;int *p, *q;
Quote:Original post by visitor
I think it might be concluded that the only things not entirely OK stylewise in C++ are declarations like:


The only things not entirely OK stylewise in C++?
Hmm, one day I want to make a game in which the entire world is (and is known to be) implemented in a programming language, and the inhabitants start hacking the very fabric of their universe for personal gain et al. Performance can be hand-waved, but for gameplay hooks I'll make both the language and the architecture of the implementation itself esoteric, unmanaged and bug-/exploit-riddled, so all sorts of crazy quirks and chaos end up plausible even before actual reflection comes into play.
"You just polluted the dimension pointers on that crate?!?"
*crate projects across x axis, vanishes*

C++'d have to be in the melting pot as far as devising the language goes, naturally. :)
Quote:
The only things not entirely OK stylewise in C++?


The only things of the ones discussed in this thread. No matter what spacing you use, declaring a mixture of pointers and non-pointers, or several pointers is going to confuse someone unnecessarily.

This topic is closed to new replies.

Advertisement