Deutsch English Français Italiano |
<va7gb3$f2d0$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Thiago Adams <thiago.adams@gmail.com> Newsgroups: comp.lang.c Subject: Re: Naming conventions (was Re: valgrind leak I can't find) Date: Thu, 22 Aug 2024 11:01:07 -0300 Organization: A noiseless patient Spider Lines: 78 Message-ID: <va7gb3$f2d0$1@dont-email.me> References: <j8idnQlHTPZXZFv7nZ2dnZfqn_GdnZ2d@brightview.co.uk> <va75pv$djqu$1@dont-email.me> <va76q6$dljb$2@dont-email.me> <1c5db75fd1fd3b0e61bd2517a38f2829d0aeee6c.camel@tilde.green> <va7el3$esrp$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 22 Aug 2024 16:01:08 +0200 (CEST) Injection-Info: dont-email.me; posting-host="85c23c65ebcc3c54f3fb7aecb1a9f458"; logging-data="493984"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18F88EqppeCgM3m18oUckOR86nnyLlYXDY=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:xxbSmY6niSVphBPeYs877D4XjJU= Content-Language: en-US In-Reply-To: <va7el3$esrp$1@dont-email.me> Bytes: 2700 On 22/08/2024 10:32, Janis Papanagnou wrote: > On 22.08.2024 14:01, Annada Behera wrote: >> On Thu, 2024-08-22 at 08:18 -0300, Thiago Adams wrote: >>> On 22/08/2024 08:01, Bart wrote: >>>> On 22/08/2024 09:41, Mark Summerfield wrote: >>>> >>>>> This is the type's struct: >>>>> >>>>> typedef struct { >>>>> int _size; >>>>> int _cap; >>>>> char** _values; >>>>> } VecStr; >>>> >>>> What's with the leading underscores for member names? > > A convention. (I.e. one convention amongst dozens.) > >>>> >>>> It means ending with ->_ later on, which seems pointless extra >>>> clutter. >>> >>> >>> C++ is responsible for this. > > I don't think so. I've seen such conventions in many places, also > very often in C contexts. Even standards use naming conventions. > (This is no valuation. I don't give a valuation. Not yet.) C++ also made the use of "struct/union/enum" before tags optional. For example: struct X x; In C++, we can write: X x; Consequence? Programmers started using a suffix "C" for classes and "E" for enums. For example: CArray array; EType type; In C, we have a similar situation where it's sometimes unclear where a variable comes from. Consider this code: void f(int arg1){ i = 2; } This can happen with external variables. For instance: int i; void f(int arg1){ i = 2; } In this situation, I use a prefix "s_" for the variable, like this: int s_i;