Sujet : Re: Whaddaya think?
De : pc+usenet (at) *nospam* asdf.org (Phil Carmody)
Groupes : comp.lang.cDate : 23. Jun 2024, 09:20:16
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <87pls883zz.fsf@fatphil.org>
References : 1 2 3 4 5 6 7 8
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Kaz Kylheku <
643-408-1753@kylheku.com> writes:
On 2024-06-17, Richard Harnden <richard.nospam@gmail.invalid> wrote:
If a function is defined to return an int, then you should return one.
>
Anything else is just lazy/sloppy. Just because main allows it as a
special case doesn't mean it's a good idea.
>
I mean: it's really not much extra to type.
>
The misfeature of missing return being success was, I believe, not
intended to make programs shorter. It was intendeda to correct the
random termination statuses of countless numbers of programs in a single
stroke.
>
Deliberately relying on this in a new program is like relying ona a
diaper. If you're of intermediate age, you don't do this.
Astronauts do this quite frequently. Some pilots too. And divers. And
crane operators. It's a well-established solution to a known problem.
However, I'd still put the explicit return in for a reason of
literal portability: were I to want to lift that code out into
a separate function called by main(), I'd want it to behave the
same.
Phil
-- We are no longer hunters and nomads. No longer awed and frightened, as we havegained some understanding of the world in which we live. As such, we can castaside childish remnants from the dawn of our civilization.-- NotSanguine on SoylentNews, after Eugen Weber in /The Western Tradition/