std.getopt suggestion

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Sep 29 08:55:39 PDT 2011


On 9/29/11 8:49 AM, Vladimir Panteleev wrote:
> On Thu, 29 Sep 2011 18:41:33 +0300, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
>
>> It would be quite abnormal to run getopt multiple times in the same
>> app with different configurations. So in this case using globals is
>> _better_, not worse.
>
> How about this: your program uses a logging component. You pass the
> command-line arguments to the logging component, so that it uses getopt
> to pick out the logging options and returns the rest.
>
> One day, the maintainers of the logging component decide to add
> compatibility with Brand X logging component, which uses ':' for the
> equal-sign separator. Naturally the maintainers are sloppy and don't
> restore the option after setting it. You know what happens next...

Sloppy maintainers may also take the GetOpt object by reference, change 
its state, and pass it back.

Andrei


More information about the Digitalmars-d mailing list