std.getopt suggestion
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sat Oct 1 13:09:20 PDT 2011
On 10/1/11 12:56 PM, Nick Sabalausky wrote:
> "Andrei Alexandrescu"<SeeWebsiteForEmail at erdani.org> wrote in message
> news:j679o0$1hdm$1 at digitalmars.com...
>> On 10/1/11 5:42 AM, Jacob Carlborg wrote:
>>>
>>> I forgot to mention that I don't want the order of the arguments to
>>> matter. I should be possible to write:
>>>
>>> "foo bar -b -a"
>>>
>>> Or at least it should be possible to put global options anywhere in the
>>> command line.
>>>
>>> So I guess that would be using the passThrough option the first time
>>> getopt is called and then using the noPassThrough option when it's
>>> called the second time from the action implementation.
>>>
>>> So there we have a use case for calling getopt more than once, at least
>>> I have a use case for that.
>>
>> Clearly there are legit use cases. The use of monostate does not impede
>> them.
>>
>
> It makes them error-prone whenever you want to use a different option.
>
> The use of Jon's suggestion does not impede the single-use cases. But it
> does make the other cases less problematic. So there's benefit with no
> downside.
I don't see it like that. Someone who's liable to make errors with one
function and three variables is just as liable to make errors with one
function and one object containing three variables.
Andrei
More information about the Digitalmars-d
mailing list