Article View: comp.lang.c
Article #1136Re: .5 against 0.5f
From: Keith Thompson
Date: Thu, 29 Oct 2026 23:29
Date: Thu, 29 Oct 2026 23:29
73 lines
4404 bytes
4404 bytes
cross@spitfire.i.gajendra.net (Dan Cross) writes:
> In article <11bvqbn$3g0tj$1@dont-email.me>,
> James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
>>On 2026-10-28 21:50, Steven G. Kargl wrote:
>>> On Wed, 28 Oct 2026 17:59:19 -0700, Tim Rentsch wrote:
>>>> "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:
>>>>> On Wed, 28 Oct 2026 16:39:00 -0700, Keith Thompson wrote:
>>>>>> (Also, you misspelled "ROFL", and you don't need parentheses on the
>>>>>> return statement, particularly if you dislike fluff.)
>>>>>
>>>>> Yeah, I was laugh too hard while typing ;-)
>>>>>
>>>>> Parentheses is a habit from BSD kernel source file style guide.
>>>>
>>>> Now is a good time to start unlearning that habit.
>>>
>>> Why? What harm do the parentheses cause?
>>
>>They can lead to people thinking that return is a function, even if they
>>nominally know better.
>
> What? This is an incredibly weak argument.
>
> If someone thought that `return` was a function, then why
> wouldn't they think that `if` or `while` were also functions?
> Or `sizeof`, and so on?
I agree that it's a bit of a weak argument, but I wouldn't call it
incredibly weak.
In my personal coding style, I try to avoid making things that are not
function calls look like function calls. In a function call, there's no
space between the function name and the left parenthesis. I don't use
that style for anything other than function calls (or invocations of
function-like macros). Not because I don't know return and sizeof are
keywords, but because it's just a little bit easier to read the code
if distinctions like that are clear.
Examples:
func(42); // function call, or maybe a macro invocation
return 42; // not return(42); or even "return (42);
if (cond) // not if(cond)
sizeof (int) // not sizeof(int)
sizeof obj // not sizeof(obj) or sizeof (obj)
The idea is to make the code just a little bit clearer and easier to
read. If I see something that looks it would be a function call except
that the prefix is a keyword, it's *very slightly* annoying.
Parentheses on a return statement are allowed, but they're part of the
expression, not part of the syntax of the return statement, and they're
superfluous. I don't write `return (42);` for the same reason I don't
write `x = (42);`.
And of course *all* of these rules can be overridden by a coding
standard or by the existing style of the surrounding code.
[...]
> But again, the whole premise (that a programmer familiar with C
> would ever think that `return` is a function) is silly.
The premise (at least for me) is not that someone would *think*
that return is a function, but that making a return statement not
look too much like a function call makes the code just a little
bit easier to read.
And in the example that started this subthread, I probably wouldn't
have mentioned the parentheses if the poster hadn't been complaining
about "fluff".
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Technical Details
Message-ID:
<11c0kst$3pmvb$2@kst.eternal-september.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!kst.eternal-september.org!.POSTED!not-for-mailReferences:
<11bpvs7$1e6kc$2@dont-email.me> <868q3hmie0.fsf@linuxsc.com> <11bu8oi$2up7m$1@dont-email.me> <11bvqbn$3g0tj$1@dont-email.me> <11c07vf$lhk$1@reader2.panix.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!kst.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson <Keith.S.Thompson+u@gmail.com> Newsgroups: comp.lang.c Subject: Re: .5 against 0.5f Date: Thu, 29 Oct 2026 16:29:32 -0700 Organization: None to speak of Lines: 73 Message-ID: <11c0kst$3pmvb$2@kst.eternal-september.org> References: <11bpvs7$1e6kc$2@dont-email.me> <868q3hmie0.fsf@linuxsc.com> <11bu8oi$2up7m$1@dont-email.me> <11bvqbn$3g0tj$1@dont-email.me> <11c07vf$lhk$1@reader2.panix.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Thu, 29 Oct 2026 23:29:33 +0000 (UTC) Injection-Info: kst.eternal-september.org; logging-data="3988459"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/rayjQFAztXzdGvTFKsyl2"; posting-host="6d0778e7cc40265319e665d37d9f3d3e" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:svoq1J37NzmuqAmSvQe1jeECPK0= sha256:obAZ8Si8KIxxpPs7HKiNRfn3D13elxs1eRmEnjLFs6k= sha1:sbOi39l4hdf7RcREQ7ArxQ5V8Tc= sha256:A7jgOarRdqW00apMFfV9C62GT1tAU8V6Sk5p9jTTYew=