Er, what?
They may have paid attention sometimes.
That would not be a suitable rule for a language standard. It might
be a suitable rule for an operating system standard.
OK, sure, that's why various operating systems have error
logging standards baked in...so what was the friggin' point
of putting in a largely useless return value in the "C" standard?
It would be a spectacularly stupid rule, though, because there are
widespread systems which have very well established rules for such
behavior.
I'm not sure I'm following...it's stupid because it's a feature
of widespread systems? Is this a back-handed MS slam?
But I GUESS what you're TRYING to say is that the return
value of main() has no particular use because the OS either
does or does not supply useful error logging, but the ANSI
C committee put it in the standard for writing scripts based
on relatively small C programs used as commands and basically
no other purpose...maybe they should have stated THAT as their
"rationale" (did they?), which would supply some actual guidance as
to under what circumstances you should set a particular value...
As it should be. If you want to do something more specific, you need to
do it in a way specific to your environment.
Or do it myself...
That's because we're talking about what actually happens in computers,
not what would have been an interesting alternative design to consider
in a parallel universe where neither Windows nor Unix existed.
No, we're not, you had your chance to prove a certain
return value could kill people, particularly without a
clear "intervening event" like some goofball writing some
dumb script that launches nuclear missiles because he
thinks that somebody is following a rule that he already
knows a lot of people don't follow...
Except that it's not unwarranted.
Yes it is...extraordinary claims require extraordinary
proof, you provided nothing other than hand-waving...
That's because the "being laughed at" was stupid and ignorant.
What have I written that would lead you to conclude I was
either stupid or ignorant, other than it is fun to insult
people who share different, possibly more correct, opinions
than you?
Maybe you should focus less on being a jerk and more on articulating
your questions, then?
What have I written that would lead you to posit I have
not asked clear articulate questions? You snipping them
out and answering questions of your own liking does not
count...
So you weren't actually asking the question you asked.
Sorry, been watching the late afternoon Conrad Murray trial
on TV, you just seem to be out of order on this topic...
Okay, you seem to be under some kind of strange delusions about the
relationship of a language standard to the rest of the world.
Well, that makes two of us, since I think we're in total agreement
that a language standard cannot control the OS...so what was the
point of passing a binary value to the OS again? Basically
scripts?
Operating systems exist, and have requirements that vary based on
what they are operating systems for.
Or the whims and/or stupidity of the OS designers...
Language specs don't get to
control that. Language specs offer limited standardized functionality,
and if you need functionality beyond what they can offer, you have to
go look at other specs.
Sure...but hey, think about this: instead of a binary value for
main(), allow the full use of the int to allow OS-specified return
values that would actually mean something...sound reasonable? Just
an idea...probably IS stupid...
If you want the *portable* C answer, the only values that mean anything
are 0, EXIT_SUCCESS, and EXIT_FAILURE, and there is no guarantee that
every operating system everywhere does anything with them.
Whew...your logic does not resemble our Earth logic...I'm not
even going to try on this one, it'd be like debating the crazy
homeless
guy shouting to himself on the street corner...
However,
realistically, any implementation that's hosted will at the very least do
something vaguely reasonable with these.
I was previously not amused with your use of the term "hosted" in
relation to Windows(TM), and it's not getting any funnier...
If you want an answer that's more specific to a platform, then your
answer necessarily depends on the specifics of that platform and
environment.
The winmain() question isn't.
It can not be topical because it turns out to be a question about specific
operating systems, to which different systems have different answers, not
a question about the language.
I guess it's always a question about pointless pedantry versus
real life...on a scale of 0 to 100 of possible PROGRAMMER errors,
"misuse" of the return value of main() is about a 0.0000000025,
and cannot reasonably foreseeably kill anybody.
You've only been told this about 8 billion times, you might
just concede that simple point and move along to something
slightly more important, like the precise average amount of
lint your navel collects in a day...
Then you'd be well served by learning that a computer system is more than
one thing. The language is not the same thing as the operating system,
which is not the same thing as the hardware. If you want to know what
specific return values do, look at the operating system, because that's what
is doing something with them.
EXACTLY. You've once again managed to expertly beg the
question, just like the crazy homeless guy begs for money...
What's really nice is another snip-a-roo so you
could do the following pointless "fancy footwork":
That is up to you and your feelings about what your specific operating
system does with the values.
No it isn't; what you snipped out was just the tip
of the iceberg of my program requirements...the OS
very kindly logs various types of Internet failures,
but I have to parse them to get to what I need to
do, and I have to do a whole lot more and of course
this has NOTHING to do with the return value of main()...
The main practical benefit is that it offers other programs a way to
find out whether your program worked without needing to know that much
about your program.
I as a person, both as the user of the program and person
who wrote to the program to do certain things, have no need
or desire to know whether my program "worked" or not, but
I have a burning need to know exactly WHY it didn't WORK
(you know, what you disingenuously snipped out).
Let's say I want to grab a bunch of files. Right now, I'm using wget:
for u in $urls; do
wget "$u"
done
What do they call this, "script kiddie" work? Yeah, I've
used that command, and I guess I could have used it in a
script to do what I wanted to do...as long as the script
was about 10 times as long as this friggin' long
post...
But I want to know which URLs to retry again later:
retry_later=""
for u in $urls; do
wget "$u" || retry_later="$retry_later $u"
done
See, it's getting longer already...now make it do the downloads
according to dozens of different schedules, making sure that it
actually has the right files, you know, the stuff you snipped
out, along with automatically placing the files in hundreds
of different directories according to the types of data, then
invoking a hundred or so file parsing routines to pull the
wanted data out and loaded automatically into my database,
you know, stuff like that...when do you think you'll have my
script ready?
I can do this, because I know that wget will "succeed" if it gets the
file, and "fail" if it doesn't-get the file. I don't have to know what
specific values it returns, and I don't really care in this case.
See, I actually kind of care, but you may have a point, if
you don't get your file, try, try again, and don't worry if
the file is corrupt, just go ahead and download it anyway,
it's easier to fix a corrupted database days or weeks later
if you're not aware of it at download...
And
if I want to switch to using Luke Mewburn's ftp instead of wget, I just do:
lukemftp "$u" || retry_later="$retry_later $u"
and so on and so forth.
And then I try the billreid downloader, and whaddya know. He returns
"success" whether or not he succeeds, so with his program, I have to do:
>/path/to/billreid.logfile
billreidget "$u"
if grep -q "FAILED" /path/to/billreid.logfile; then
retry_later="$retry_later $u"
fi
... which works, because I know that grep will indicate success or failure
appropriately.
Yeah, I guess we work on two entirely different levels of
software...
The thing is, in the real world, people will sometimes do stuff like
# see whether we can grab specification file
if wget "$specfile_url"; then
program_robot "$specfile"
fi
because they know that they'll know whether the application succeeded or
failed.
And if someone then comes in and says "I'll return success unless there was
a system error of some sort, even if I do not actually succeed in achieving
the task I was assigned, because I can just look in the log files", someone
ends up programming the robot with stale data, or a corrupted file, or...
Yeah, that was exactly why I don't use the "script kiddie"
approach, I'm watching a scheduled download now, it's giving me
all the information on success or failure, a few days ago one
of the "5pm weekdays except certain holidays" files was retitled
and I got an error message, which automatically pulled up
the file so I could get the new title string, I selected
the download configuration menu item and replaced the
string to look for with the new one and now I don't get
the message anymore...sure am sorry I don't rely on the
return value of main()...
And yes, we mostly know better, and people are usually pretty careful with
this kind of thing. Usually. But there are people killed every year
because software fails, and software fails in part because people don't
do error checking, and they don't do error checking because people think
it's hilarious overdramatization to imagine that anyone could actually be
hurt if you don't check errors or provide the error indicators that people
would be checking for...
Give it up...I've told you at least a dozen effin' times
my goal is to get much more PRECISE error messages to avoid
any type of unwanted error, and I just don't get that from
main()...aren't you worried that you're confusing the
"children", or is that your goal?
But a big part of the problem is that you're expecting a language standard
to dictate terms to operating systems, when it actually goes the other way;
operating systems dictate what can be implemented on them, language standards
look for things they can expect everyone to provide some way of handling.
Nope. If it's undefined, it's a waste of time, and the
return value of main() is for all practical intents and
purposes undefined, except for "script kiddies"...
Virtually all operating systems can distinguish in some way between
"success" and "failure" of a program.
Sure, "running" or "not responding" seem to be popular...
If you need more than that, you are
outside what a language standard can possibly specify, because not all
operating systems have more than that.
Well, sure, and in many cases I have to provide it
myself, maybe just for the sake of the holy "portability"
(remember, my own error logging written in "C" is fully
portable as long as it doesn't rely on OS-specific logging)...
So, again: If you want more information than this, go read the specs for
the operating system or systems you care about, but it's not going to be
a feature of this language or any other, because languages don't get to
decide what operating systems do or don't support.
EXACTLY. Thanks for agreeing with me, AND for calling
me an "idiot" and "ignorant" in the process...