Flag & byLine confusion.

Steven Schveighoffer schveiguy at gmail.com
Sun Dec 20 15:04:29 UTC 2020


On 12/20/20 9:07 AM, Rekel wrote:
> Does this mean other flag yes's will not be accepted?

The long and short of it is that Flag is supposed to make you NAME what 
your flag is for.

The idea is to prevent things like:

byLine(true);

Reading the code, what does "true" mean? You have to look up the 
documentation to see what it is. And then you might have things like:

foo(true, true, false, true);

What do all those mean?

Instead, you have to name what the flag is for:

byLine(KeepTerminator.yes);

The Yes/No structs and Flag structs are there to help you name your 
flag, and have some awkward D way to do this.

This will likely all go away in the future with named parameters 
(deprecating Flag is one of the reasons named parameters were 
proposed/accepted).

I personally avoid Flag in my code because I think it's awkward and 
cumbersome.

-Steve


More information about the Digitalmars-d-learn mailing list