command line options

Stan Switzer sjs at spectral.ctt.bellcore.com
Tue Apr 5 00:23:27 AEST 1988


> In article <761 at srs.UUCP> srs!dan at cs.rochester.edu (Dan Kegel) writes:
> ]We've recently been mulling over what would be better than getopt().
	. . .
> o Non-switch positional arguments should be allowed.
> o The caller should be able to step through the list of arguments which
>   were ignored by the argument processor.
	. . .
> o The argument processor shouldn't use any static or global variables
> o It should allow the caller to do as much of the error handling as desired.

In article <26550 at cca.CCA.COM> g-rh at CCA.CCA.COM.UUCP (Richard Harter) writes:
> o	The argument processor should be a one call routine, a contrasted
> 	to getopt, which is called once for each argument.
 
All of these considerations suggest that getopt()' should be a coroutine
style function.  Harking back to a week-old discussion, I propose that a
coroutine mechanism (actually some sort of policy-free state freeze/thaw)
would greatly help in solving this sort of problem.  The getopt()' coroutine
would be instantiated with an argument vector, then be (co)invoked once
per argument.  Semantic error notifications could be conveyed back to
getopt()' via the (co)returns.

(In fact the Sys V getopt() routine does approximate this approach by
using external variables and a bizarre calling convention.  It just doesn't
generalize.)

Just another simple example of where coroutines can simplify things...

Stan Switzer   sjs at ctt.bellcore.com -or- bellcore!ctt!sjs



More information about the Comp.unix.wizards mailing list