main() return type convention [was Re: Linux compiling]
From: Anthony Borla (ajborla_at_bigpond.com)
Date: 12/06/04
- Next message: Paul F. Johnson: "My brains have gone dry and flakey - I can't get this to work!"
- Previous message: Anthony Borla: "Namespace Qualification [was Re: Linux compiling]"
- In reply to: Anand Hariharan: "Re: Linux compiling"
- Next in thread: Tabrez Iqbal: "Re: Linux compiling"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 06 Dec 2004 13:51:03 GMT
"Anand Hariharan" <mailto.anand.hariharan@gmail.com> wrote in message
news:22868227.0412031503.74a1bca7@posting.google.com...
> Alwyn <alwyn@blueyonder.co.uk> wrote in message
news:<pan.2004.12.03.07.51.36.638908@blueyonder.co.uk>...
> > On Thu, 02 Dec 2004 21:04:40 -0600, Jack Klein wrote:
> > >
<SNIP>
>
> What possibly annoys the gurus (like Jack) is that main's
> return type is something so easy to get it right, that they find
> it irksome when folks "refuse" to get it right.
>
I'm not sure folks so much 'refuse' as some just don't know any better. This
is certainly applicable to novices and students who are simply following the
examples provided to them by their teachers, and the authors of various
programming books and tutorials.
In other situations, say professional developers targeting a single platform
with a particular development tool [e.g. Win32 GUI applications using MS
VC6++], standards-conformance may simply not be an issue. Instead, all that
counts for them is that the compiler emit code that works reliably on the
target platform, and whether it is standards-compliant or not, is moot.
According to:
http://www.eskimo.com/~scs/readings/voidmain.960823.html
it would seem that the practice commenced with professional developers
taking steps to eliminate compiler errors or warnings [thus, inadvertantly
creating incorrect code], and was propogated via authors / teachers using
such incorrect code in their examples.
>
> Sometimes, I speculate, that it might have something to do
> with an antipathy towards Microsoft (VC6 almost enforces
> void main, and MSDN is replete with void main examples)
>
And those code examples are very likely to remain there since 'old code
never dies' :) !
>
> and/or Sun (Java's equivalent of main returns void).
>
Although Java is, syntactically, in the C / C++ family of languages, you
should not assume that idioms / conventions applicable to either of the
former also apply to it [and vice versa].
As regards returning a value to the host operating system:
* It is not performed via a 'return' from Java's 'main' equivalent
* A programmer may specify a return code via the 'System.exit()'
method [similar to exit() or std::exit()], but this is entirely
optional - a default value is returned if such a value is
required
* The Java runtime [JVM] takes care of supplying a default
return value to the operating system *on systems that require
it*; a programmer cannot therefore write an application that
behaves erratically due to a return value issue
Cheers,
Anthony Borla
- Next message: Paul F. Johnson: "My brains have gone dry and flakey - I can't get this to work!"
- Previous message: Anthony Borla: "Namespace Qualification [was Re: Linux compiling]"
- In reply to: Anand Hariharan: "Re: Linux compiling"
- Next in thread: Tabrez Iqbal: "Re: Linux compiling"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|