Deutsch English Français Italiano |
<20240617003207.452@kylheku.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Kaz Kylheku <643-408-1753@kylheku.com> Newsgroups: comp.lang.c Subject: Re: Whaddaya think? Date: Mon, 17 Jun 2024 07:39:36 -0000 (UTC) Organization: A noiseless patient Spider Lines: 57 Message-ID: <20240617003207.452@kylheku.com> 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> Injection-Date: Mon, 17 Jun 2024 09:39:36 +0200 (CEST) Injection-Info: dont-email.me; posting-host="05bafc0e4e4620b91ac884490c0b1f07"; logging-data="585479"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18lwINR2xT6tKk1OkF6Ax6NKHkCClEt13M=" User-Agent: slrn/pre1.0.4-9 (Linux) Cancel-Lock: sha1:xYbvgOtNqgaBeajfvZ2r3xGJf5g= Bytes: 3225 On 2024-06-17, James Kuyper <jameskuyper@alumni.caltech.edu> 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. I think DFS might mean that they find themselves unable to omit the unnecessary return 0 statement entirely. I also hate it; I feel that the implicit return 0 in main is a misfeature that was added due to caving in to bad programmers. Making int main(void) { } correct is like legalizing weed. Potheads are still potheads. Since I'm not one, I write a return statement in main. > 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. Speaking of while, the do/while construct does not require parentheses in order to disambiguate anything, since it has a mandatory semicolon. Yet, it still has them. There would be no issue with this grammar: iteration_statement := 'do' statement 'while' expression ';' the fragment "'while' expression ';'" is exactly like "'return' expression ';'". Obviously, the parentheses are there for consistency with the top-testing while loop. It seems that in some people's eyes, the same consistency should extend to the return statement. More widespread than that is a practice of always using parentheses around the argument of sizeof, even if it's an expression and not a type. -- TXR Programming Language: http://nongnu.org/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal Mastodon: @Kazinator@mstdn.ca