Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!munnari.oz.au!metro!usage.csd.unsw.oz.au!syacus!william From: william@syacus.acus.oz (William Mason) Newsgroups: comp.lang.c++ Subject: Re: Can you prototype main() ????? Message-ID: <1070@syacus.acus.oz> Date: 19 Sep 90 09:00:08 GMT References: <14227.26dc5b2f@max.u.washington.edu> <24447@uflorida.cis.ufl.EDU> <59517@bbn.BBN.COM> Organization: Australian Centre for Unisys Software, Sydney Lines: 50 saustin@bbn.com (Steve Austin) writes: >bp@swamp.cis.ufl.edu (Brian Pane) writes: >I don't think it make much sense at all to prototype main. You prototype a >function in order to call it - I don't know what you would get if you tried to >call main, but I bet it wouldn't be good. Also, if you do manage to prototye >main, you will be asking for its name to be mangled, which will not please your >linker. While agreeing with the practical sentiment of this statement, I would like to suggest that there is a place for "prototyped main()-s" out there some where. Visualise an object oriented operating system ... (pretend it looks like a Mac or OS/2-PM, i.e. WIMPS-ish). Now in this environment I have a program "display.c" with overloaded and proto-typed main()-s. Each main() represents a different input for the display tool. For example: int main( postscript ){...} int main( troff ) {... } int main( GIFF ){...} Now, the actual implementation need not be one executable with multiple entry points (shades of FORTRAN). I would expect the compiler or pre-processor to generate a normal argc and argv style for the real main() and inside this the appropriate overloaded main() could be called. What is happening is that the (possibly GUI) shell is co-operating with the compiler to supply the correct switches so the real main() gets the correct information. The supposed shell could be primitive and only look at file type or it could use some resource file, etc. to effect the desired behaviour from "display". The important thing is that a lot of operating system interface messyness is done away with. Extensions to the model would allow environmental variables as main() parameters or defaults. E.g.: int main( Postscript_File pf, Device_type dt = $(TERM), ){ ... } Some of this functionality was part of the Pascal language, but only file parameters were allowed. The Microsoft Pascal extended this other types (it does prompt but I can't remember if it takes 'things' from an MS-DOS command line). Thanks for your time, William Mason ACUS Sydney.