Sujet : Re: question about linker
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.lang.cDate : 03. Dec 2024, 16:36:59
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vin8is$584m$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 03.12.2024 16:00, David Brown wrote:
A general guideline followed by most people is to have the length of
identifiers (or their semantic content) increase with larger scope of
the identifier. "i" is fine as a counter of a small loop, but you would
not want to use it for a file-scope static.
We've basically had just two types; semantical entities with
explicit names, and local technical entities. But we anyway
hadn't handled that too strictly; feedback from code-reviews
corrected the worst excesses, or suggested name alternatives.
[...]
But I dislike it when people use things like "indx" for "index" or "cnt"
for "count".
(I also dislike saving single characters "indx" or "creat()".)
Actually in local contexts (small scope) I have no issues with
writing 'c' instead of 'count', or 'msg' instead of 'message'.
The terser formulation (in a local structure) I think usually
increases readability.
Typically 'count' appears not being better than 'c' since both
are technical entities and don't carry semantical information,
in contexts like 'count++' or 'c++' you see it's counting even
when writing 'x++' or 'foobar++'.
Where the semantics of such an entity is relevant its name was
even larger, like, say, 'inhabitants_count'. Or you may even
strip the technical count 'inhabitants++', or 'nof_inhabitants'
(we used the common "number of ..." abbreviated as "nof_...").
Janis