std.getopt suggestion

Vladimir Panteleev vladimir at thecybershadow.net
Thu Sep 29 08:49:55 PDT 2011


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...

-- 
Best regards,
  Vladimir                            mailto:vladimir at thecybershadow.net


More information about the Digitalmars-d mailing list