The D Scripting Language

Tomek Sowiński just at ask.me
Thu Nov 11 13:21:14 PST 2010


Steven Schveighoffer napisał:

>> I still don't see added value over the existing situation. Currently
>> getopt leaves whatever wasn't an option in args[1 .. $] (without
>> shuffling order), so the code above would simply use args[1] for expr
>> and args[2 .. $] for files.
> 
> 1. uses same type check/conversion that is used for options

Yeah,

auto args =["numcruncher.exe", "-avg", "-med", "5", "3", "4.5", ".8"];
bool avg, med; double[] numbers;
getopt(args, "avg",&avg, "med",&med, &numbers);

> 2. Less boilerplate code.
> 
> For 2, without anonymous options, you either use args[1] everywhere, or
> you assign args[1] to a variable at the top.  To just do it in one line is
> convenient, I kind of like the idea.

Yes. Why should getopt do just half of the job when it can do most, and for 
cheap? Again, small implementation effort in the denominator boosts the ROI of 
this development to lucrative levels.

-- 
Tomek


More information about the Digitalmars-d mailing list