× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 2010/11/6 4:58 AM, dieter.bender@xxxxxxxxxxxx wrote:
... it doesn't make too much sense to me to have a possibility to name a
program entry point "exit". If its named main then its meant as program
entry point, in rpg you are ending up with H main(main) to clearify that
main should be real program entry point. ...

Dieter, naming a program entry procedure "exit" doesn't make too much sense to me either, unless the program's purpose is to exit something.

You're right that if you always call your main procedure "main", then it will seem stupid to have to code main(main) in every program. But RPG isn't the same as C. For RPG, the main procedure is called by the same name as the prototype that callers will use to call the program. Naming every RPG procedure "main" will require you to have two different prototypes for the program; one called "main" for defining the main procedure, and one called "somethingElse" for calling the program.

The problem with "main" for C is that the prototype for the program can't be used to verify that the main procedure is coded to match the prototype. The benefit for C is that the program entry procedure is always called "main", which is a nice self-documenting feature.

The benefit for RPG is that the same prototype can be used both for calling the program and for defining the program entry procedure, allowing the compiler to verify that the prototype matches the procedure. The problem with RPG is that it doesn't have the direct self-documenting feature of having the PEP named "main". But instead, it has the MAIN keyword which has almost the same self-documenting benefit.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.