Breaking Long Lines

Thomas Doerfler thomas.doerfler at embedded-brains.de
Tue Nov 10 07:38:14 UTC 2020


Hi,

Am 10.11.20 um 06:33 schrieb Chris Johns:
> On 9/11/20 5:50 pm, Sebastian Huber wrote:
>> On 09/11/2020 01:52, Chris Johns wrote:
>>
>>> On 6/11/20 7:11 pm, Sebastian Huber wrote:
...
>>>
>>>   Avoid excess parentheses. Learn the operator precedence. rules.
>>
>> Yes, and I think this is a good rule.
> 
> I am not sure it is a good rule and workable. Using it to handle indents is an
> example of it breaking down. The ability to control an indent is a long held
> tradition and editors like Emacs are designed to handle it yet it is not clear
> if it is OK under this rule.
> 

I tried not to jump in for more than 24 hours. But now I want to drop in
my opinion. What is the whole purpose of a style guide? Is it to have a
nice looking code layout, neat an tidy like a ideal front garden, or is
it about readability/accessibility? We could write the whole of a C
module into one line and it could work anyway, so what about a style guide?

IMHO it should improve readability and understanding of what goes on in
a certain module. The code should be readable and understandable not
only for highly experienced C programmers, but also for newbies (if they
tr<y hard enough).

Now back to paranthesis: Since we are very frugal with comments, we
should at least make complex expressions easier to read by structuring
them, where convenient, with parenthesis where it improves readability.

An alternative rule like "Learn the operator precedence" could lead to a
similar sentence "Learn C block structure" to eliminate any code
indentation rules, because these rules have the ONLY purpose to make the
underlying code block structure easier to visualize and comprehend.

So: my counter-rule would be "use paranthesis if you think it makes an
expression easier to understand".

Looking forward to resonpses ;-)

Thomas.

-- 
--------------------------------------------
embedded brains GmbH
Thomas Dörfler
Dornierstr. 4
82178 Puchheim
Germany
email: thomas.doerfler at embedded-brains.de
Phone: +49-89-18 94 741 - 12
Fax:   +49-89-18 94 741 - 09
PGP: Public key available on request.

embedded brains GmbH
Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/


More information about the devel mailing list