Sujet : Re: Whaddaya think?
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 18. Jun 2024, 11:07:10
Autres entêtes
Organisation : None to speak of
Message-ID : <87r0cuzhrl.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6 7
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Janis Papanagnou <janis_papanagnou+
ng@hotmail.com> writes:
On 17.06.2024 16:41, Ben Bacarisse wrote:
DFS <nospam@dfs.com> writes:
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!
>
This is an interesting observation! (That I can confirm.)
>
That's probably why originally I also used parenthesis.
I saw the examples but didn't inspect the syntax appendix.
>
But how did the early compiler behave?
Did they follow the code samples' syntax or the formal syntax?
The syntax in the 1975 C reference manual required parentheses as part
of the syntax of a return statement:
return ;
return ( expression ) ;
By 1978, when K&R1 was published, the syntax had changed to:
return ;
return expression ;
If you write `return (42);`, even in modern C, it's still syntactically
valid. The parentheses are simply part of the expression, not part of
the syntax of the return statement.
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.
>
I dropped them as soon as I noticed that it's possible.
My personal preference (which I don't follow entirely consistently) is
to try to avoid making things that aren't function calls look too much
like function calls.
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */