Deutsch English Français Italiano |
<87o77zvdgy.fsf@bsb.me.uk> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!feeds.phibee-telecom.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse <ben@bsb.me.uk> Newsgroups: comp.lang.c Subject: Re: Whaddaya think? Date: Mon, 17 Jun 2024 15:41:17 +0100 Organization: A noiseless patient Spider Lines: 45 Message-ID: <87o77zvdgy.fsf@bsb.me.uk> References: <666ded36$0$958$882e4bbb@reader.netnews.com> <87ed8x4zjl.fsf@nosuchdomain.example.com> <666f10b7$0$1412896$882e4bbb@reader.netnews.com> <v4o7om$er18$1@dont-email.me> <667030fa$0$7079$882e4bbb@reader.netnews.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Mon, 17 Jun 2024 16:41:17 +0200 (CEST) Injection-Info: dont-email.me; posting-host="f69b21fe46179def9aae9c77317b77e3"; logging-data="754711"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/1NCWdnhMb+W8ZAmAmnZ/kU1bOlzbgwGg=" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:Gi0ZcV56/tTTPZdrbPioaqqIAew= sha1:oxRIOiNN+5tHh4tqokatL7R7AAg= X-BSB-Auth: 1.4c8b3bf63509f14a4684.20240617154117BST.87o77zvdgy.fsf@bsb.me.uk Bytes: 3091 DFS <nospam@dfs.com> writes: > On 6/16/2024 10:41 PM, James Kuyper wrote: >> On 6/16/24 12:20, DFS wrote: >>> On 6/15/2024 6:22 PM, Keith Thompson wrote: >>>> DFS <nospam@dfs.com> writes: >> ... >>>>> return(0); >>>> >>>> A minor style point: a return statement doesn't require parentheses. >>>> IMHO using parentheses make it look too much like a function call. I'd >>>> write `return 0;`, or more likely I'd just omit it, since falling off >>>> the end of main does an implicit `return 0;` (starting in C99). >>> >>> Can't omit it. It's required by my brain. >> The parentheses you're putting in are completely unrelated to the use of >> parentheses in _Generic(), function calls, compound literals, >> sizeof(type name), alignof(), _BitInt(), _Atomic(), typeof(), >> typeof_unqual(), alignas(), function declarators, static_assert(), if(), >> switch(for(), while(), do ... while(), function-like macro definitions >> and invocations or cast expressions. In all of those cases, the >> parentheses are part of the grammar. >> The parentheses that you put in return(0) serve only for grouping >> purpose. They are semantically equivalent to the parentheses in "i = >> (0);"; they are just as legal, and just as pointless. >> If your brain doesn't immediately understand why what I said above is >> true, I recommend retraining it. > > I meant omit a return altogether. > > But looking around, I rarely see return(0). Don't know why it became a > thing for me. > > Moving forward, return 0 it is. By the way, you might have retained return (exp); from old C. C originally required the parentheses, but they got dropped quite early on. The syntax in K&R (1st edition) does not require them, but almost all the code example in the book still have them! I took a while to drop them as I came to C from B where they were always required so I'd got the habit. -- Ben.