Re: Whaddaya think?

Liste des GroupesRevenir à l c 
Sujet : Re: Whaddaya think?
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.lang.c
Date : 17. Jun 2024, 09:16:00
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v4onrg$hmc2$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 17.06.2024 08:20, Keith Thompson wrote:
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
On 16.06.2024 22:32, Keith Thompson wrote:
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
[...] K&R at
least seems to say that 'void' can only be declared for the
return type of functions that do not return anything.
[...]
>
No version of C has ever permitted "void main" except when an
implementation documents and permits it.  [...]
>
I cannot comment on main() being handled differently than
other C functions. I was just quoting my old copy of K&R.
 
First or second edition?

It's a translation of a "(c) 1977 Prentice Hall" original, with
no further edition mentioned, so it's probably the 1st edition?

 
But main() *is* handled differently than other functions,

Be assured, I don't object! It was just not mentioned that it's
a special case.

and
that's important to understand.  It's effectively called by the
environment, which means that your definition has to cooperate
with what the environment expects.

I'm not sure whether my K&R copy addresses that at all. A quick
view and I see only one instance where "main()" is mentioned at
the beginning:   main() { printf("hello, world\n"); }
No types here, and no environment aspects mentioned.

Also mind that (other) languages don't need to interact with the
environment. Just recently I noticed that the Algol 68 Genie
does not pass the value of the outmost block to the environment.
Environment questions, interaction with the OS, may not be part
of the language. (I'm not saying anything about the C standard
[that I don't know]. Just a comment in principal.)

What's slightly weird about
it is that it can be defined in (at least) two different ways,
with or without argc and argv.

Frankly, I have no idea about the details of evolution of the
C language. The old K&R source I have I had considered a pain;
it provoked more questions than giving answers. And since then
C changed a lot. That's why I stay mostly conservative with C
and if in doubt check things undogmatic just with my compiler.

[...]
 
If I want a defined exit status (which is what I usually
want) I specify 'int main (...)' and provide an explicit
return statement (or exit() call).
 
Why would you ever not want a defined exit status, given that it's
easier to have one than not to have one?

Aren't we agreeing here? (The only difference is that you are
formulating in a negated form where I positively said the same.)

(Since C99 an explicit
return or exit() is optional.)  I can't think of any reason *at all*
to use "void main" in C with a hosted implementation.  Can you?

Well, to indicate that there's no status information or that
it's irrelevant. E.g. as was the case in the test fragment I
posted.

In programs I typically write there's a lot things that can
possibly go wrong - and that the program cannot fix -, mostly
(but not exclusively) externalities. So it's typical that I
interrogate return status of functions, map them to a defined
set of return codes, create own codes for data inconsistencies
etc. And this status is relevant and of course returned to the
environment (often accompanied by some textual information on
stderr).

(If you don't care about the exit status, you can just write
"int main" and not bother with a return statement or exit() call.
The exit status will be 0, but that's not a problem if you don't
care about it.)

Whatever current C standards - and I'm not sure what ancient
'cc' is on my system and to what standard it complies - say,
if I specify an 'int' return type I also want a 'return' (or
exit()) - consider it as "code hygienics" - even if it's not
necessary according to more recent standards.

Janis


Date Sujet#  Auteur
15 Jun 24 * Whaddaya think?96DFS
15 Jun 24 +- Re: Whaddaya think?1Malcolm McLean
16 Jun 24 +* Re: Whaddaya think?5Ben Bacarisse
16 Jun 24 i+* Re: Whaddaya think?2bart
16 Jun 24 ii`- Re: Whaddaya think?1Ben Bacarisse
16 Jun 24 i`* Re: Whaddaya think?2DFS
17 Jun 24 i `- Re: Whaddaya think?1Ben Bacarisse
16 Jun 24 +* Re: Whaddaya think?23Keith Thompson
16 Jun 24 i`* Re: Whaddaya think?22DFS
16 Jun 24 i +- Re: Whaddaya think?1Keith Thompson
17 Jun 24 i +* Re: Whaddaya think?19James Kuyper
17 Jun 24 i i+- Re: Whaddaya think?1Tim Rentsch
17 Jun 24 i i+* Re: Whaddaya think?13Kaz Kylheku
17 Jun 24 i ii+- Re: Whaddaya think?1Chris M. Thomasson
17 Jun 24 i ii+* Re: Whaddaya think?6DFS
17 Jun 24 i iii`* Re: Whaddaya think?5Richard Harnden
17 Jun 24 i iii +- Re: Whaddaya think?1David Brown
23 Jun 24 i iii `* Re: Whaddaya think?3Kaz Kylheku
23 Jun 24 i iii  +- Re: Whaddaya think?1Keith Thompson
23 Jun 24 i iii  `- Re: Whaddaya think?1Phil Carmody
18 Jun 24 i ii`* Re: Whaddaya think?5Tim Rentsch
18 Jun 24 i ii `* Re: Whaddaya think?4Keith Thompson
19 Jun 24 i ii  `* Re: Whaddaya think?3Tim Rentsch
19 Jun 24 i ii   `* Re: Whaddaya think?2Keith Thompson
19 Jun 24 i ii    `- Re: Whaddaya think?1Kaz Kylheku
17 Jun 24 i i`* Re: Whaddaya think?4DFS
17 Jun 24 i i `* Re: Whaddaya think?3Ben Bacarisse
18 Jun 24 i i  `* Re: Whaddaya think?2Janis Papanagnou
18 Jun 24 i i   `- Re: Whaddaya think?1Keith Thompson
17 Jun 24 i `- Re: Whaddaya think?1James Kuyper
16 Jun 24 +* Re: Whaddaya think?60Michael S
16 Jun 24 i+* Re: Whaddaya think?58Lawrence D'Oliveiro
16 Jun 24 ii`* Re: Whaddaya think?57Janis Papanagnou
16 Jun 24 ii +* Re: Whaddaya think?8Keith Thompson
16 Jun 24 ii i+- Re: Whaddaya think?1Lawrence D'Oliveiro
16 Jun 24 ii i`* Re: Whaddaya think?6Janis Papanagnou
16 Jun 24 ii i `* Re: Whaddaya think?5DFS
16 Jun 24 ii i  `* Re: Whaddaya think?4David Brown
16 Jun 24 ii i   +* Re: Whaddaya think?2bart
17 Jun 24 ii i   i`- Re: Whaddaya think?1David Brown
17 Jun 24 ii i   `- Re: Whaddaya think?1DFS
16 Jun 24 ii +* Re: Whaddaya think?45Janis Papanagnou
16 Jun 24 ii i`* Re: Whaddaya think?44Keith Thompson
16 Jun 24 ii i `* Re: Whaddaya think?43Janis Papanagnou
16 Jun 24 ii i  +* Re: Whaddaya think?20Keith Thompson
16 Jun 24 ii i  i`* Re: Whaddaya think?19Janis Papanagnou
16 Jun 24 ii i  i +* Re: Whaddaya think?2Malcolm McLean
16 Jun 24 ii i  i i`- Re: Whaddaya think?1Janis Papanagnou
16 Jun 24 ii i  i `* Re: Whaddaya think?16Keith Thompson
17 Jun 24 ii i  i  `* Re: Whaddaya think?15Janis Papanagnou
17 Jun 24 ii i  i   +* Re: Whaddaya think?12Keith Thompson
17 Jun 24 ii i  i   i`* Re: Whaddaya think?11Janis Papanagnou
17 Jun 24 ii i  i   i +* Re: Whaddaya think?5James Kuyper
18 Jun 24 ii i  i   i i+- Re: Whaddaya think?1Keith Thompson
18 Jun 24 ii i  i   i i`* Re: Whaddaya think?3Janis Papanagnou
18 Jun 24 ii i  i   i i +- Re: Whaddaya think?1James Kuyper
18 Jun 24 ii i  i   i i `- Re: Whaddaya think?1Keith Thompson
18 Jun 24 ii i  i   i `* Re: Whaddaya think?5Keith Thompson
18 Jun 24 ii i  i   i  +- Re: Whaddaya think?1Janis Papanagnou
19 Jun 24 ii i  i   i  `* Re: Whaddaya think?3Keith Thompson
19 Jun 24 ii i  i   i   `* Re: Whaddaya think?2David Brown
19 Jun 24 ii i  i   i    `- Re: Whaddaya think?1Keith Thompson
17 Jun 24 ii i  i   `* Re: Whaddaya think?2James Kuyper
17 Jun 24 ii i  i    `- Re: Whaddaya think?1Janis Papanagnou
16 Jun 24 ii i  +* Re: Whaddaya think?7Michael S
16 Jun 24 ii i  i`* Re: Whaddaya think?6Janis Papanagnou
16 Jun 24 ii i  i `* Re: Whaddaya think?5Michael S
16 Jun 24 ii i  i  `* Re: Whaddaya think?4Janis Papanagnou
16 Jun 24 ii i  i   `* Re: Whaddaya think?3Michael S
16 Jun 24 ii i  i    `* Re: Whaddaya think?2Janis Papanagnou
16 Jun 24 ii i  i     `- Re: Whaddaya think?1Michael S
17 Jun 24 ii i  `* Re: Whaddaya think?15Keith Thompson
17 Jun 24 ii i   +* Re: Whaddaya think?11Tim Rentsch
17 Jun 24 ii i   i+* Re: Whaddaya think?8Janis Papanagnou
17 Jun 24 ii i   ii+* Re: Whaddaya think?6DFS
17 Jun 24 ii i   iii+* Re: Whaddaya think?2Chris M. Thomasson
18 Jun 24 ii i   iiii`- Re: Whaddaya think?1Keith Thompson
18 Jun 24 ii i   iii+* Re: Whaddaya think?2Keith Thompson
18 Jun 24 ii i   iiii`- Re: Whaddaya think?1David Brown
18 Jun 24 ii i   iii`- Re: Whaddaya think?1Janis Papanagnou
18 Jun 24 ii i   ii`- Re: Whaddaya think?1Tim Rentsch
17 Jun 24 ii i   i`* Re: Whaddaya think?2James Kuyper
19 Jun 24 ii i   i `- Re: Whaddaya think?1Tim Rentsch
17 Jun 24 ii i   `* Re: Whaddaya think?3Janis Papanagnou
17 Jun 24 ii i    `* Re: Whaddaya think?2Keith Thompson
17 Jun 24 ii i     `- Re: Whaddaya think?1Janis Papanagnou
16 Jun 24 ii +- Re: Whaddaya think?1Malcolm McLean
16 Jun 24 ii `* Re: Whaddaya think?2Michael S
16 Jun 24 ii  `- Re: Whaddaya think?1Janis Papanagnou
16 Jun 24 i`- Re: Whaddaya think?1DFS
16 Jun 24 `* Re: Whaddaya think?6Lew Pitcher
16 Jun 24  +- Re: Whaddaya think?1Malcolm McLean
18 Jun 24  +- Re: Whaddaya think?1Lawrence D'Oliveiro
25 Jun 24  `* Re: Whaddaya think?3Lew Pitcher
25 Jun 24   `* Re: Whaddaya think?2DFS
25 Jun 24    `- Re: Whaddaya think?1Lew Pitcher

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal