want to know

Badger BA 64810 bbadger at x102c.harris-atd.com
Thu Aug 17 03:41:01 AEST 1989


In article <1701 at crdgw1.crd.ge.com> davidsen at crdos1.UUCP (bill davidsen) writes:
>  If you really want to have a program which enters somehere else write
>a dummy main:
>	main(argc, argv, env)
>	int argc;
>	char *argv, *env;
>	{ exit(yourname(argc, argv, env)); }
>
>  I totally fail to see what the advantage of using another name is, but
>I'm sure someone finds it aestheticaly (sp?) pleasing.
>	bill davidsen		(davidsen at crdos1.crd.GE.COM)

I have problems with ``main'' from two different directions.

Firstly, it is less informative to the user.  Having a fixed entry like main
removes the possibility of a descriptive name being applied to a program.
It also interferes with naming conventions for files and cross-reference tools
like ctags.  Our local ctags has been modified to substitute ``Mfoo'' for 
the symbol ``main()'' found in file ``foo.c''.  This kind of game wouldn't
be required if C let you choose your main program name.

Secondly, I don't really like the idea of having a _single_ entry point 
to a program.  I prefer a scheme which allows any external function to 
be called from the command line.  You can distinguish a single function 
as the main entry.  Of course, yo without requiring that it be the _only_ 
entry.  There are lots of UNIX programs written to simulate this by 
switching on the value of argv[0] (the name the program was invoked by --
see vi/ex, [ec]tags for examples), but this facility could be legitimized
by providing an entry point specification in exec().  It's worth noting 
that the debugger can call any subroutine at any time.  What sort of 
command line syntax should be used for multi-entry point programs?  The 
biggest problem with this sort of scheme is how to process the arguments 
for arbitrary types of function arguments.  In closed single-language systems
(lisp and some ada environments come to mind) the command line parser 
is part of the compiler, and can manage this.  The debugger can typically 
do this, too, though only for the program being debugged.


Bernard A. Badger Jr.	407/984-6385          |``Use the Source, Luke!''
Secure Computer Products                      |``Get a LIFE!''  -- J.H. Conway
Harris GISD, Melbourne, FL  32902             |Buddy, can you paradigm?
Internet: bbadger%x102c at trantor.harris-atd.com|'s/./&&/g' Tom sed expansively.



More information about the Comp.lang.c mailing list