C++ problem

But we've seen this, right? Primarily for "cardinality" #defines, having them be all caps is a clue that they may be just that.

I can't see it as pernicious.

Les Cargill
Reply to
Les Cargill
Loading thread data ...

As pointed out here before: no, it's not. It comes quite close, but it's not the same. And for better of for worth, that difference has a _very_ long tradition of being indicated by one being all-caps, the other not.

The original rule since the very invention of the language has always been: everything #define'd is spelled in all caps; the language standard itself also follows that rule quite consistently. Now, one may not like that, but that won't change history, and it's this history which influenced all those code style rules out there.

As to this kind of spelling being perceived as an eyesore, one thing to keep in mind is that back when this convention was set up, all the usual languages around wouldn't even distinguish letter case in identifiers _at_all_, and they were typically taught, printed and even practically written in ALL_CAPS. I.e. the general perception of ALL_CAPS as SHOUTING is quite possibly younger than the original C naming convention.

That is IMHO a corner case, and thus purely a matter of style (or externally defined style rules).

In a case like that, the history of the thing in question may become the governing factor. E.g. if it started out as a #define (or even still is a #define in other versions of the source), before it was reduced to a static const variable, by all means keep it capitalized. If it started out as an external const variable (usually with a module name prefix), or used to be an ordinary variable, it may retain the spelling those versions had, instead.

Reply to
Hans-Bernhard Bröker

For a simple defined literal, there is no practical difference in most use-cases, and no danger of mistake in the use-cases where there /is/ a difference.

(Note that I am not arguing here against the use of all-caps for macros that might have more issues, and for where an all-caps warning can be a useful thing.)

This amounts simply to "we use all-caps for macros because we use all-caps for macros". It is not a justification or reasoning in itself. It is not unreasonable to say that it one should follow conventions simply because they are conventions (as noted earlier, consistency of style is very important) - but I am trying to see if there are any reasons other than convention. So far, no one has come up with anything that comes close to convincing me.

Again, this is just history. Computers of that day did not support colour or graphics - does that mean we should not provide colourful windowed interfaces on PC programs? The limitations of old computers does not affect the appearance of all-caps names as being highly emphasised when reading a modern program on a modern computer.

I agree that it does not make sense to change the spelling/appearance of something whose functionality has not significantly changed.

Reply to
David Brown

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.