Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: operator precedence
Date: Mon, 25 Apr 2022 11:10:58 -0700
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <86v8ux58zx.fsf@linuxsc.com>
References:
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="2b2bd3060d7fb14ae545fc6b32585799"; logging-data="20117"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX195G8NijEAk0s7O7n1zhOvw0pcsB/5beBU="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:AoYT50TtlfX6GziY1+ZedD1jqt8= sha1:1T8QC2zNYbXSS+6YT4VDA1tCKRg=
Xref: csiph.com comp.lang.c:165929
Guillaume writes:
> Le 08/04/2022 at 14:00, Stefan Ram a ecrit:
>
>> Recently, I wrote:
>>
>> board & 1 << row * COLS + col
>
> If I saw this coming from someone in my team, I would probably fire them. =)
>
> I'm not even sure this is correct from what you really intended. But
> even if it is, there's a rule in programming, IMO, that's above the
> programming language's grammar: readability for us humans.
>
> Code we write is meant for humans, not machines. That's something
> people forget way too often. That's why we write using higher-level
> languages, not assembly or even machine code. Or, look at the
> obfuscated C contest and such. This is proper C from a language
> standpoint, but nothing you'd want to deal with.
>
> The readability rule that applies here is, if you need more than a few
> seconds figuring out what a given statement exactly does, and may have
> to even open the C standard to make sure, then it's badly
> written. Rewrite it.
Human readability can be improved as follows:
board & 1 << row*COLS+col