Deutsch   English   Français   Italiano  
<vple07$26nr0$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Janis Papanagnou <janis_papanagnou+ng@hotmail.com>
Newsgroups: comp.lang.c
Subject: Re: Which code style do you prefer the most?
Date: Tue, 25 Feb 2025 22:51:01 +0100
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <vple07$26nr0$1@dont-email.me>
References: <vpkmq0$21php$1@dont-email.me>
 <XnsB29169B4B7798hueydlltampabayrrcom@135.181.20.170>
 <vpknua$21ti1$1@dont-email.me> <u2mvP.1403901$z8ke.1254798@fx15.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 25 Feb 2025 22:51:03 +0100 (CET)
Injection-Info: dont-email.me; posting-host="d49f883feaf566fa61db3752b5c99fde";
	logging-data="2318176"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+45bhPRJwv4PfdZ1SgoQZC"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
 Thunderbird/45.8.0
Cancel-Lock: sha1:8ndGBSvbTN8k79FUwIHg78xedfg=
In-Reply-To: <u2mvP.1403901$z8ke.1254798@fx15.iad>
X-Enigmail-Draft-Status: N1110
Bytes: 3936

On 25.02.2025 17:17, Scott Lurndal wrote:
> Ar Rakin <rakinar2@onesoftnet.eu.org> writes:
>> On 2/25/25 9:23 PM, David LaRue wrote:
>>> I used a style similar to this in school.  Before that I used much the same.
>>> As for existing code bases I prefer to keep their style and add comments
>>> accordingly.  That generally goes for any language.
>>
>> Agreed. For existing projects, the code style should be preserved.
>>
>>> Popularity of a style shouldn't be a goal.  It should be consistantly
>>> readable and documented.  We must write for ourselves as well as our future
>>> self and others.
>>
>> This is true. I just wanted to know which style most people seem to prefer.
>>
>> Thanks for your response!
> 
> I prefer the AT&T style (which you call GNU style, but which actually
> predates Stallman).
> 
> The vi(1) editor has several commands that are designed to support
> the AT*T (or more properly, Bell Labs) style, such as the '[['
> and ']]' commands.  

For non-Vi/Vim users it may be useful to point out that there's so
many navigation commands for all sorts of syntactical constructs,
whether editing programming languages, prose text, or data, that
you can choose your preferred way - and there are typically more
ways than just one - to navigate to any entity.

> Starting a function definition with
> the function name in column 1 enables the use of the VI
> 
>  /^main
> 
> command to easily move the cursor to the start of a named function.

Yeah, I know that "advantage" from some projects; I never liked the
function return type to be on a separate line, though. (And I never
felt a need for that search in the first place. - Occasionally (but
rarely) I worked with Vi-supported tags. Mileages vary, of course.)

I'm fine with just searching the function name and typing 'n' or 'N'
to reach other places. - With Vim, BTW, there's the nice command to
"jump to definition" (with 'gD'); and this function is independent
of whether the name is (without spaces) left aligned in column 1 or
somewhere else. So I can just search '/' without '^' and optionally
'gD' in case I've not landed in the definition already. That command
also works with items other than function names, e.g. with variable
definitions or function parameters that I also don't want to have
separated from its type [just to serve the editor].
(Disclaimer: I've used this feature only in C and C++ so I can't tell
suitability for other common languages. But see the note above about
the many powerful language-agnostic positioning options in Vi/Vim.)

Generally I prefer to not have the editor impose the "rules" for
source code formatting in any language. (Again, YMMV.)

Janis