On Sunday, 20 December 2020 at 15:04:29 UTC, Steven Schveighoffer
wrote:
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
With named parameters, do you refer to python-esque function
calls?
That makes a lot more sense to me personally, although I'm only
just learning D, as I likewise wouldnt use `Number!"Wheels".4`
for a function call.
By the way, where can I see Flag is (/ will be?) deprecated? It
doesn't show in the library reference, however I may be looking
in the wrong place.