On 9/28/11 12:44 PM, Jonathan M Davis wrote:
Okay. I have a suggestion for an improvement to std.getopt that I think merits
a bit of discussion. There's currently a pull request with some improvements
for getopt which are mostly internal changes rather than API changes (
https://github.com/D-Programming-Language/phobos/pull/272 ), but I think that
there is an API change that we should consider.

Right now, there are three configuration options which are mutable module-level
variables:

dchar optionChar = '-';
string endOfOptions = "--";
dchar assignChar = '=';

and the aforementioned pull request adds another for an array separator.
Mutable module/global variables are generally considered to be bad design
(though they're sometimes necessary), and I'm very much inclined to have those
variables _not_ be at the module scope like that.

Why?

So, my suggestion is that we create a GetOpt struct which contains all of the
options for getopt, and we make getopt a member function of that struct.

If the only motivation is that "globals are bad" without further reasoning, I see this as keeping with the letter but not with the spirit of the law.


Andrei

Reply via email to