Re: The worst 'hello world' example ever written...

J

James Lothian

The_Sage said:
And you are basing that on just one compiler?

In particular, the MS compiler that you had just confidently asserted
would accept this. Please run this example through whatever compiler
you have access to and show us the compiler's diagnostic output.
 
D

David B. Held

Noah Roberts said:
[...]
I see what the misunderstanding is. "Sage" thinks that the
above means that all implementations must have at least
one main that returns an int. The problem is caused by a
misunderstanding of the sentance:

No, I'm afraid you're mistaken. This is about the 5th time
or so that he's made this claim, every single time being
soundly refuted. He doesn't "misunderstand" it. He merely
thinks that if he asserts the claim long enough, the laws of
the universe will change in such a way that it becomes true.
Either that, or people will eventually give up and leave him
alone, at which point he will insist that by their silence,
everyone is conceding the point.

To believe anything different is to give him far more credit
than he deserves.

Dave
 
D

David B. Held

James Lothian said:
[...]
In particular, the MS compiler that you had just
confidently asserted would accept this. Please run this
example through whatever compiler you have access to
and show us the compiler's diagnostic output.

I'm afraid that's not possible. He would be proving a claim
that he's made, and since he hasn't made any claims that
are true, it's impossible for him to prove any of them. In
fact, he hasn't even answered half the challenges so far,
including a challenge to cite documentation or official public
statements by the vendors he has named that their compilers
are indeed 100% ISO conforming.

Dave
 
D

David B. Held

The_Sage said:
[...]
Nope. Truth is not always fact, like the Gospel Truth for
example, which is not based on facts.

By definition, truth is fact. Calling something true, like "void
main() is legal C++" does not make it truth, or a fact.
Yes it is.

So you concede the point. At last. Unfortunately, you must
have a very short memory, because in this very same post,
you insist that it's not. Perhaps this part of the post was
written by that inner child that wants to admit the truth,
and you merely succeeded in suppressing it before
continuing with your post.
Too bad none of them have actually read the standard.

Prove it. Considering that at least one of them is on the C++
committee, it seems extremely unlikely that that is the case.
Considering that the relevant portion of the standard has
been quoted at least 4 times, it seems unlikely that *any*
of them have *not* read the appropriate part of the
standard. Are you capable of saying *anything* that is
true?
I can read where the standard says you can return other
types for main()

Maybe you are reading something other than the standard?
also, ie -- int is mandatory to include in a compiler, but
void is an optional alternate.

Thus far, you have failed to provide a reference to the
standard which shows that this is the case. On the contrary,
the standard explicitly disallows this very thing, and it has
been demonstrated to do so numerous times, yet you
ignore every single explanation. Perhaps you're illiterate,
and are incapable of reading the portion of people's posts
that explains how "must return type int" does not mean
"may return type void".
[...]
<Snipped the whining bullshit>

Oh, are you referring to the part where you accused me
of calling people names, and then I cited about 12 quotes
where you completely lost any semblance of reason and
resorted to childlike name-calling (this post being a case in
point)?
[...]
This right here proves just how illiterate you are. Let's
take a look at that statement again, and see just what it
says...

That's a very good idea.
How many versions of main() can I return according to that
article? One? Two? As many as I like? The answer is: As
many as I like.

So far, so good.
So let's see, if I have a compiler and it has two types of main,
one which returns an int and another which returns a void,
has it violated the ISO standard?
Yes.

The answer is: No, because the compiler can have as many
versions of main as it likes, just so long as one of those types
is an int.

And which part of the standard says "just so long as one of
those types is an int"? Is the the part that you scribbled into
your copy of the standard? Or was this part of the standard
revealed to you by the Great Unicorn? Funny enough,
nobody else can manage to see the part of the standard which
says this, which perhaps means it was written in invisible ink
to foil us simple-minded programmers.

Perhaps you'd like to show me the logical reasoning which
leads you to conclude that:

"they must all have" <==> "just so long as one has"

Now, let's apply your reasoning to other things in the world
and see if it makes sense. Imagine a rule that says all people
on board an airplane must be wearing their seatbelts when
the fasten seatbelt sign is illuminated. By your logic, the
following two rules are equivalent:

"When the fasten seatbelt sign is illuminated, the passengers
must all have their seatbelts securely fastened"

"When the fasten seatbelt sign is illuminated, at least one
passenger must have his/her seatbelt securely fastened"

Now, I'm pretty sure with this illustration, even a 5 year old
would be able to see the fallacy of your logic. But just to
further humiliate you, I will give one more illustration:

"In order for The Sage's brain to produce meaningful output,
all of his neurons must be functioning."

Or your version:

"In order for The Sage's brain to produce meaningful output,
just one neuron needs to be functioning."

In this case, I will grant that there is an equivalency in the two
statements, but only because "all" in this case degenerates to
"one". The same is not true for allowed forms of main().
It also doesn't make it illegal.

It doesn't need to make it illegal. The standard already does
that. The point of this claim is that there are no other
provisions which make it legal.
Haha! Who cares what other "programmers" like you
consider?

When you have to get a new job because you got fired for
ranting and raving about the legality of "void main()", perhaps
you will care very much what other programmers think of
you.
Wow! I'm really scared by that serious threat. I'm not
afraid of people who can't understand the simple english
of a standard and claim that a simple three line program
has five errors, even though those who bothered to
compile it could never get more than one. Haha! Please,
get serious! Haha!

Actually, the compiler is not required to diagnose every
error in a program. It is theoretically impossible for it to do
so. In particular, it is not generally possible for the compiler
to diagnose every program which results in undefined
behaviour. Thus, the number of diagnostics reported by
the compiler is not at all indicative of the number of errors
contained in the program. Furthermore, even if it were
possible, the number of diagnostics produced would only
be relevant if all the compilers used were 100% conforming,
and you haven't even named the one vendor that has such
a compiler (or is believed to).

Dave
 
D

Duane Hebert

However, the following is not:
void main( anything );

because it does not conform to "they must all have return type int".

Once again:

"A conforming implementation may provide more versions of main(), but
they must all have return type int."

The subject of "they must all have return type int" is the additional
main signatures, NOT the compiler implementation. It is too bad english
is such a subpar language.

There's no problem with the English language.
A conforming implementation may provide more versions (this mean that in
addition to
int main(int argc, char **argv) they may provide additional versions of the
function main as
long as the return type is int.

The standard says that if no return is specified, main returns 0. That in
itself prevents void main().
Check my previous post. There's a link to Stroustrups FAQ with a response
to this question. He wrote the
language. If he says main returns an int who am I to argue? Besides, what
difference does it make anyway?
 
R

Randall Hyde

David B. Held said:
I'm afraid that's not possible. He would be proving a claim
that he's made, and since he hasn't made any claims that
are true, it's impossible for him to prove any of them. In
fact, he hasn't even answered half the challenges so far,
including a challenge to cite documentation or official public
statements by the vendors he has named that their compilers
are indeed 100% ISO conforming.

:)
The C++ newsgroup is beginning to catch on.
"The_Sage" has never backed up a single assertion
he has made. He loves to throw around terms like
"intellectual dishonesty" and "logical fallacy" while
intentionally stating the opposite of the truth (there
is no way he can claim ignorance [nor is there any
way he *would* claim ignorance] for his misposts;
they are intentional, done just to incite).

He once made a 19-point list of "facts" he'd gleaned
from a web site that had the hidden agenda of supporting
Ada and demanded that myself and others debate these
points. I broke them out one by one and agreed to his
little debate. He stuck his tail between his legs and ran.
Unfortunately, I didn't give him any manuvering room to
pull his usual 1:pass off untruths as facts, 2:resort to name
calling, 3:change the subject, 4:go on and argue about
something else. Frankly, I'm surprised he's stuck with
this semicolon issue as long as he has; normally he has
changed the subject and quietly moved on to something
else long before now. I guess he really like people thinking
none-to-high of his intellectual and debating skills.
Cheers,
Randy Hyde
 
B

Buster

Noah Roberts said:
The problem is caused by a misunderstanding of the sentance:

"A conforming implementation may provide more versions of main(), but
they must all have return type int."

The subject of "they must all have return type int" is the additional
main signatures, NOT the compiler implementation. It is too bad english
is such a subpar language.

That's brilliant. Really, well done.

Buster
 
C

Chris Johnson

[snip]

The truly sad part of this entire thread is that you do not seem to:
A) Realize people will use this group as a form of study
B) Realize that you may have a very real mental disorder

I regret to contribute to this noise level in this group but I have
had about all I can take of your ignorance. You are definitely one
of the better trolls I have seen in my time. So in effect - you have
that concession from me. It's truly ashame you can not make any
concessions yourself about being wrong, but that is not what trolls
do.

Please understand that you are doing a disservice to the many people
who do wish to better themselves by blathering off the ridiculous
statements that you do. I do not wish to engage in name calling as
you so often seem to do but I can only gather that you have no life,
very immature, or you are in desperate need is mental help.
(Perhaps all three?)

Reasoning with you only seems to contribute to your mental dementia.
I have no other recourse but the following:

*PLONK*
 
K

Kwailo

No, no no. It says that main's type, OTHER THAN its return value
(which is
Wrong again. It clearly said *return* type, not parameter. Try another lame
guess.

The Sage
It says "Return type of type int, otherwise its type is implementation
defined".
Again, repeat slowly: Return type: int, rest of type: impl. defined.

Kwailo
 
M

Mitch Crane

It shall have a return type of type int

-->BUT<--

otherwise its type is implementation-defined"

"return type" ... "otherwise its type"

You seem to have confused yourself. Note that it doesn't say "otherwise
its return type..."
Duh! The int is mandatory but void is optional.

I guess that might make sense if it could return have both at the same
time. You live in an interesting world where mandatory things are not
required.
 
M

Mitch Crane

And you are basing that on just one compiler? How come it compiles on
mine?

Because yours is allows non-standard code. Is that really so hard to
understand? Are you under the impression that non-standard code never works
on any compiler?
 
A

Attila Feher

The_Sage wrote:
[SNIP]
Get a clue all you other idiots out there:

There is only one idiot posting into this thread.
The ISO standard says it
is okay to use "void main()" but even if you want to blindly and
ignorantly deny that fact,

The ISO standard says it is forbidden to use void as the return type of
main.
then explain why MS, Borland, and IBM all
agree with my interpretation of the ISO standard?

For backwards compatibility of their non-standard times and compilers.
If you can't answer
that question with something other than a blatent make believe
assertion, ie -- something other than your meresay or hearsay, say a
real life quote from one of those organizations to the effect of
"Opps! We thought we were ISO complaint but I guess we really
aren't".

OK. If I make the C++ community liaison of Microsoft (who happens to be the
convenor of the C++ standardization committee) to tell you that void main is
illegal will you shut up?

This is what Microsoft says as allowed main function signatures. Note that
there is *no* main returning void:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html
/vclrfstandardcomplianceissuesinvisualc.asp

Temporary short URL for the above:
http://tinyurl.com/o787

About Microsoft compliance statement:
"Microsoft extensions to the ANSI standard are noted in the text and syntax
of this book as well as in the online reference. Because the extensions are
not a part of the ANSI standard, their use may restrict portability of
programs between systems. By default, the Microsoft extensions are enabled.
To disable the extensions, specify the /Za compiler option. With /Za, all
non-ANSI code generates errors or warnings."


Or should I get Bjarne Stroustrup (the creator of the C++ language) to tell
you? Or this is not good for you since you have already ignored Andrew
Koening, who is the closest thing to Stroustrup? Should I ask Francis
Glassborow (and Oxford scholar and member of the C and C++ committees) to
tell you that you are wrong?
 
K

Karl Heinz Buchegger

T.M. Sommers said:
The only people who have to remember are the compiler writers. The
rest of us can put a return at the end of main(), and forget that it
isn't necessary.

I'm not saying that implicit return 0 is the greatest thing since
sliced bread, just that it is a defensible decision on the part of the
committee.

I see your point and I agree: it's not that big of a deal.
But I also see Beth's point and she has a point there:
Why have a special rule for something which really is not
a problem and just brings up confusion?
If somebody would bring up a vote, if this rule should be
dropped, I would vote with a loud and clear: YES!
Compilers get changed, millions of programmers spend 30 seconds
on adding the missing return 0; and can turn to more important
things afterward. The standard gets corrected and gets shortened
(IMHO a good thing) and compiler writes don't have to spend a thought
about a special case in the data flow analysis for checking if a function
actually returns something in all cases except main(). But other then
that: the earth still revolves the same way.

But I agree: It is certainly not a topic to make a big fuzz about.
 
H

Herb Sutter

Subclause 3.6.1, paragraph 2:

An implementation shall not predefine the `main' function.
This function shall not be overloaded. It shall have a return
type of type `int,' but otherwise its type is implementation-
defined. All implementations shall allow both of the following
definitions of `main':

int main() { /* ... */ }

and

int main(int argc, char* argv[]) { /* ... */ }

When the C++ standard uses the word ``shall'' in this way, it
expresses a requirement on programs that every standard-conforming
implementation is required to enforce, at least by producing a
diagnostic message (which might be only a warning) for any program
that does not meet the requirement.

Right. To elaborate on Andy's note, any conforming C++ implementation can
have "conforming extensions," which means extensions that do not alter the
meaning of any valid standards-conforming C++ program but cause the
compiler to also accept (and give meaning to) programs that are not
standard C++ programs.

This is summarized in 1.4 [intro.compliance], paragraph 2:

- If a program contains no violations of the rules in this
International Standard, a conforming implementation shall, within
its resource limits, accept and correctly execute that program.

In other words, a conforming implementation must accept all conforming
programs. Natch. The next two bullets cover the two major categories of
conforming extensions:


- If a program contains a violation of any diagnosable rule, a
conforming implementation shall issue at least one diagnostic
message, except that

In other words, the C++ standard declares certain kinds of code to be
unacceptable _and_ requires the compiler to emit a diagnostic for said
code. A conforming implementation can still accept the code anyway as an
extension, but it is still required to emit a diagnostic (even if the
diagnostic is just a warning).

Example: void main() {} // conforming extension if a warning is emitted


- If a program contains a violation of a rule for which no diagnostic
is required, this International Standard places no requirement on
implementations with respect to that program.

In other words, the C++ standard declares certain kinds of code to be
unacceptable (or just dubious) but does not require a diagnostic. A
conforming implementation can still accept the code anyway as an extension
if it wants to, with or without issuing a diagnostic.

Example: int main( float ) {} // conforming extension, with or
// without a warning

Strictly speaking, a compiler that permits `main' to return void does
not conform to the standard

This is correct if the compiler does not emit a diagnostic when the
extension is used. A conforming compiler can accept "void main() {}" as
long as it emits a warning for it.

Herb

---
Herb Sutter (www.gotw.ca)

Convener, ISO WG21 (C++ standards committee) (www.gotw.ca/iso)
Contributing editor, C/C++ Users Journal (www.gotw.ca/cuj)
Visual C++ program manager, Microsoft (www.gotw.ca/microsoft)
 
A

Attila Feher

Herb Sutter wrote:
[SNIP]
This is correct if the compiler does not emit a diagnostic when the
extension is used. A conforming compiler can accept "void main() {}"
as long as it emits a warning for it.

Just to clarify it a bit further. This means that a compiler accepting void
main and issues diagnostics is a conforming one, but the program code
itself, which has the void main declaration/definition in it is not
standards conforming. Can you confirm that?
 
H

Herb Sutter

Herb Sutter wrote:
[SNIP]
This is correct if the compiler does not emit a diagnostic when the
extension is used. A conforming compiler can accept "void main() {}"
as long as it emits a warning for it.

Just to clarify it a bit further. This means that a compiler accepting void
main and issues diagnostics is a conforming one,

Yes, of course assuming it is otherwise conforming. Put another way:
Accepting "void main()" does not in itself make a compiler nonconforming.
That is a conforming extension, as long as the compiler still emits a
warning.
but the program code
itself, which has the void main declaration/definition in it is not
standards conforming. Can you confirm that?

Right, such a program is not a standard C++ program. It makes use of a
common but still nonstandard C++ extension.

Herb

---
Herb Sutter (www.gotw.ca)

Convener, ISO WG21 (C++ standards committee) (www.gotw.ca/iso)
Contributing editor, C/C++ Users Journal (www.gotw.ca/cuj)
Visual C++ program manager, Microsoft (www.gotw.ca/microsoft)
 
D

David B. Held

Attila Feher said:
Herb Sutter wrote:
[...]
Just to clarify it a bit further. This means that a compiler
accepting void main and issues diagnostics is a conforming
one, but the program code itself, which has the void main
declaration/definition in it is not standards conforming.
Can you confirm that?

I would guess that code which utilizes an "extension" to
the standard is, by definition, not standard-conforming.
Also, this quote seems appropriate:

- If a program contains a violation of any diagnosable rule,
a conforming implementation shall issue at least one
diagnostic message, except that

Since "void main()" clearly "violates a diagnosable rule",
it doesn't matter if a compiler accepts it as an extension
or not...it's not conforming. I think an easily understandable
analogy would be Borland's __property extension. No
conforming C++ compiler could be expected to compile
this code:

class foo
{
__property int bar;
};

Whether some compiler chooses to accept this code as
an extension or not causes no doubt as to whether this is
conforming code or not.

Dave
 
H

Herb Sutter

Attila Feher said:
Herb Sutter wrote:
[...]
Just to clarify it a bit further. This means that a compiler
accepting void main and issues diagnostics is a conforming
one, but the program code itself, which has the void main
declaration/definition in it is not standards conforming.
Can you confirm that?

Just to fix what might look like a misattribution: Note Attila wrote the
above, I didn't. :)
I would guess that code which utilizes an "extension" to
the standard is, by definition, not standard-conforming.

Right. The compiler that accepts the extension, however, can still be
perfectly standards-conforming.
analogy would be Borland's __property extension. No
conforming C++ compiler could be expected to compile
this code:

class foo
{
__property int bar;
};

Whether some compiler chooses to accept this code as
an extension or not causes no doubt as to whether this is
conforming code or not.

Just to avoid confusion, maybe saying it this way would be clearer: The
above code is not well-formed standard C++ code. A conforming C++ compiler
is free to accept the code anyway, even though the standard does not
require the compiler to accept the code.

Herb

---
Herb Sutter (www.gotw.ca)

Convener, ISO WG21 (C++ standards committee) (www.gotw.ca/iso)
Contributing editor, C/C++ Users Journal (www.gotw.ca/cuj)
Visual C++ program manager, Microsoft (www.gotw.ca/microsoft)
 
D

David B. Held

Herb Sutter said:
Attila Feher said:
Herb Sutter wrote:
[...]
Just to clarify it a bit further. This means that a compiler
accepting void main and issues diagnostics is a conforming
one, but the program code itself, which has the void main
declaration/definition in it is not standards conforming.
Can you confirm that?

Just to fix what might look like a misattribution: Note Attila
wrote the above, I didn't. :)

Sorry. I included an extra line, obviously.
[...]
Just to avoid confusion, maybe saying it this way would
be clearer: The above code is not well-formed standard
C++ code. A conforming C++ compiler is free to accept
the code anyway, even though the standard does not
require the compiler to accept the code.

Yes, that is probably a better way to say it. Lucky for us,
it does not support the argument that "If a conforming
compiler accepts it, then it is conforming code", which
the OP attempted to advance numerous times
(disregarding the glaring truth that most compilers are, in
fact, not very conforming).

Dave
 
T

The_Sage

Reply to article by: "Kwailo said:
Date written: Mon, 22 Sep 2003 11:08:10 +0200
MsgID:<[email protected]>
It says "Return type of type int, otherwise its type is implementation
defined".
Again, repeat slowly: Return type: int, rest of type: impl. defined.

Glad to see you finally got it right. Now if you could read the next sentence
which says other return types may be implemented, ie -- the return type of void
may be implemented.

The Sage

=============================================================
My Home Page : http://members.cox.net/the.sage

"The men that American people admire most extravagantly are
most daring liars; the men they detest the most violently are
those who try to tell them the truth" -- H. L. Mencken
=============================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,281
Latest member
Pedroaciny

Latest Threads

Top