obsolete D libraries/modules

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Sep 2 09:28:56 PDT 2013


On 9/1/13 10:20 AM, Jacob Carlborg wrote:
> On 2013-09-01 16:28, Andrei Alexandrescu wrote:
>
>>> string outputFile;
>>> getopt(args, "output", &outputFile).min(2).max(4).restrict("a", "b",
>>> "c", "d");
>>
>> What would this line do?
>
> The "output" argument expects at least two values and at most four. The
> values can be "a", "b", "c" or "d".

So output should probably be a string[].

We're looking at:

enforce(output.length >= 2 && output.length <= 4.
    "Incorrect number of outputs passed");
enforce(["a", "b", "c", "d"].any(output),
    "Invalid value for output");

This is a one-time work per program. Granted, error messages could be 
nicer so that's a couple more lines. The gain from integrating such 
checks would be small.


Andrei




More information about the Digitalmars-d mailing list