Return value from getopt?

Janice Caron caron800 at googlemail.com
Wed Jan 23 00:44:19 PST 2008


In the documentation for std.getopt, the function

    bool getopt(T...)(ref string[] args, T opts);

is documented. All the inputs are well described, however, the meaning
of the return value is not described at all. All of the example code
disregards the return value completely. We are given absolutely no
clue as to what the return value means.

If I had to guess, I'd guess that true means success and false means
failure ... or possibly the other way round. But ... if either of
these possibilities are true, then surely that violates the D
principles established in the document

    http://digitalmars.com/d/2.0/errors.html

To quote bits of that: To deal with these possible errors, tedious
error handling code must be added to each function call.  ...  Good
error handling code tends to clutter up what otherwise would be a neat
and clean looking implementation. ...

It basically goes on to say that "the D way" is just to throw an
exception if things go wrong.

So my question is: is the return value of getopt meaningful, or is it
just an error indicator?

If the first case, please can it be documented?
If the second case, please can the function signature be changed to
return void, and an exception thrown on error?

Thanks



More information about the Digitalmars-d mailing list