| Deutsch English Français Italiano |
|
<vq92c7$2bdt3$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: Wed, 5 Mar 2025 09:35:17 +0100
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <vq92c7$2bdt3$1@dont-email.me>
References: <vpkmq0$21php$1@dont-email.me>
<20250304175602.c9fe683d678d3a2ed101a4ac@g{oogle}mail.com>
<vq75k8$1t6ut$2@dont-email.me> <vq785i$1u7v7$1@dont-email.me>
<20250304101022.154@kylheku.com> <vq7shq$226p3$1@dont-email.me>
<vq7u5u$21gol$2@dont-email.me> <vq8kul$29gdt$1@dont-email.me>
<vq8sul$2af0l$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 05 Mar 2025 09:35:19 +0100 (CET)
Injection-Info: dont-email.me; posting-host="c7b28c7b2c5da4ab81c18f27a162cf8b";
logging-data="2471843"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/UGHyPPSdaCWAGmRxBVOhL"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:0i/EC7UPsI+VmAKiDQK3myoCCIo=
In-Reply-To: <vq8sul$2af0l$1@dont-email.me>
X-Enigmail-Draft-Status: N1110
Bytes: 2984
On 05.03.2025 08:02, vallor wrote:
>
> It may forever label me as a pariah, but if I were writing
> this for myself, I'd probably put it:
>
> if (
> (a != b && c != d && e != f)
> ||
> (g = h() * i() && (j = k)
> )
Why "pariah"?
That looks (while maybe not prevalent) quite clear and sensible.
It hasn't prevented you from a missing parenthesis, though. ;-)
There's a reason why I dislike languages whose syntax is cluttered
with parentheses, compared to (for example)
IF a /= b AND c /= d AND e /= f
OR
g = h * i AND j = k
THEN
(Note that this code is not equivalent to the "C" code (assignment
vs. equality test)[*]. It should just illustrate what it means if all
those spurious parenthesis are omitted from a language. Of course
you can also add parenthesis around the 'AND' expressions to make
things clear. But 'if' or functions without parameters don't need
parenthesis [in other non-"C"-like languages].)
Janis
[*] The sample based on Algol 68 doesn't treat an 'int' as a 'bool'.
So functionally more equivalent something like this may be given
IF a /= b AND c /= d AND e /= f
OR
(g := h * i; g /= 0) AND (j := k; j)
assuming j, k be bools, or (j := k; j != 0) if they are ints.
Pascal has a similar parenthesis-free syntax concerning the control
constructs and parameterless functions, but (surprisingly) they had
decided to have relational expressions written in parenthesis in
such contexts: (a <> b) AND (c <> d) AND (e <> f)
> {
> foo();
> }
>
> [...]