๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #1138

Re: .5 against 0.5f

#1138
From: Keith Thompson
Date: Thu, 29 Oct 2026 23:46
63 lines
4250 bytes
"Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:
> On Thu, 29 Oct 2026 10:45:16 +0100, David Brown wrote:
>> 
>> Let me put it another way.  What benefit do you think there is from 
>> these parentheses?  Why does the FreeBSD style guide recommend them?  I 
>> can see benefits in consistency of style once that usage has been 
>> established, but why have them in the first place?
>
> As we all know, FreeBSD is derived from software developed by
> the CSRG at UC Berkeley during the 70's.  FreeBSD adopted the
> Kernel Normal Format (KNF) from CSRG.  You will need to contact
> a former member of CSRG such as Bostik, McKusick, Joy, Leffler,
> etc. and them why KNF requires ().
>
> Perhaps, the C compiler from 40 or so years ago required
> parentheses in a return statement.  Or, just maybe, members of
> CSRG read K&R and noticed the authors of the book consistently
> use paretheses in their examples.  Ah yes, let's look at
> the documentation:
>
> % man 9 style
>
> HISTORY
>      This manual page was originally based on the src/admin/style/style file
>      from the 4.4BSD-Lite2 release, with frequent updates to reflect the
>      current practice and desire of the FreeBSD project.
>      src/admin/style/style is a codification by the CSRG of the programming
>      style of Ken Thompson and Dennis Ritchie in Versionย 6 AT&T UNIX.
>
> So, it seems to be a preference of Ritchie.

A former preference.

In the 1975 C reference manual, the syntax for a return statement was:

    return ;
    return ( expression ) ;

In K&R1, 1978, the syntax was changed to:

    return ;
    return expression ;

but parentheses were used in the examples.

In K&R2, 1988, the examples did not use parentheses on return
statements.  (I don't know whether that was Ritchie's decision or
Kernighan's.)

It appears that the FreeBSD style rule is a relic of an earlier
version of C that required the parentheses.  AT&T V6 Unix was
released in 1975.

You can still use parentheses on return statements if you want to,
and you should do so if you're operating under a coding standard
that requires them.  They're part of the syntax of the expression,
not part of the syntax of the return statement.  I probably wouldn't
have said anything if you hadn't mocked the use of 25.0 or 25.0f
rather than 25 as "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: <11c0lsu$3pmvb$3@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-mail
References: <11bpvs7$1e6kc$2@dont-email.me> <11bqnvh$1np7s$1@dont-email.me> <11br5td$1to7l$1@dont-email.me> <11br792$1u7e5$1@dont-email.me> <11brgqf$21170$2@dont-email.me> <11brkco$21oj5$1@dont-email.me> <11bs4tj$26daj$1@dont-email.me> <11bs613$26knh$1@dont-email.me> <11bt7ff$2i0ag$1@dont-email.me> <11btm2a$2ojn1$2@kst.eternal-september.org> <11bttrp$2qvg6$1@dont-email.me> <11bu12l$2rgo2$4@kst.eternal-september.org> <11bu3kk$2svh8$1@dont-email.me> <868q3hmie0.fsf@linuxsc.com> <11bu8oi$2up7m$1@dont-email.me> <11bv4jd$37ch9$1@dont-email.me> <11bvsj4$3g32k$1@dont-email.me>

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:46:38 -0700
Organization: None to speak of
Lines: 63
Message-ID: <11c0lsu$3pmvb$3@kst.eternal-september.org>
References: <11bpvs7$1e6kc$2@dont-email.me> <11bqnvh$1np7s$1@dont-email.me>
	<11br5td$1to7l$1@dont-email.me> <11br792$1u7e5$1@dont-email.me>
	<11brgqf$21170$2@dont-email.me> <11brkco$21oj5$1@dont-email.me>
	<11bs4tj$26daj$1@dont-email.me> <11bs613$26knh$1@dont-email.me>
	<11bt7ff$2i0ag$1@dont-email.me>
	<11btm2a$2ojn1$2@kst.eternal-september.org>
	<11bttrp$2qvg6$1@dont-email.me>
	<11bu12l$2rgo2$4@kst.eternal-september.org>
	<11bu3kk$2svh8$1@dont-email.me> <868q3hmie0.fsf@linuxsc.com>
	<11bu8oi$2up7m$1@dont-email.me> <11bv4jd$37ch9$1@dont-email.me>
	<11bvsj4$3g32k$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 29 Oct 2026 23:46:39 +0000 (UTC)
Injection-Info: kst.eternal-september.org;
	logging-data="3988459"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18pN6uprOZ5RWY93M2RKdP6"; posting-host="6d0778e7cc40265319e665d37d9f3d3e"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:xXIqMV4SzvnyZ0RUha8JoX/x2CE= sha256:j/SbmM5wqFiuzjnvBSEcXoAIsEPcPi3QmVa7Ofj8fgA=
	sha1:zc+iZORyYKmzI9O4IO31e0FW23g= sha256:/2M7nFQCeokIrQdSjoT7xT6xCTHarLCcnqxRiJKWnqQ=