Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!agate!helios.ee.lbl.gov!nosc!logicon.arpa!trantor.harris-atd.com!x102c!bbadger From: bbadger@x102c.harris-atd.com (Badger BA 64810) Newsgroups: comp.lang.c Subject: Re: want to know Message-ID: <2538@trantor.harris-atd.com> Date: 16 Aug 89 17:41:01 GMT References: <8487@bsu-cs.bsu.edu> <2980@solo9.cs.vu.nl> <182@sunquest.UUCP> <14269@haddock.ima.isc.com> <1496@l.cc.purdue.edu> <1701@crdgw1.crd.ge.com> Sender: news@trantor.harris-atd.com Reply-To: bbadger@x102c.harris-atd.com Organization: Harris GISD, Melbourne, FL Lines: 42 In article <1701@crdgw1.crd.ge.com> davidsen@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@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@trantor.harris-atd.com|'s/./&&/g' Tom sed expansively.