Flag proposal
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Fri Jun 10 13:58:19 PDT 2011
On 6/10/11 3:30 PM, Nick Sabalausky wrote:
> I really see Flag more as a way to try to rationalize avoiding adding named
> parameters to the language.
There are fights that I believe are important and others that I think
are less so. I find name parameters nice to have but more in the second
category. There's just so much stuff that's more important.
> And yes, the legibility of "foo(Flag!"param".yes, Flag!"otherParam".no);",
Fair point. I figured this should be easier:
foo(yes!"param", no!"otherParam");
See
https://github.com/andralex/phobos/commit/84c75336a4ef04b4c3b1924d7ac9329e744ab8e7
> combined with the frequency of need for such a thing,
People have found 7 uses of the yes/no enum pattern in Phobos plus a
couple others where it should - in 135KLoC.
> and the complete
> inability of Flag to address the problem for anything but bool,
Flag can be made to incorporate arbitrary categorical types, I just
haven't done that yet so as to not complicate implementation too early.
> the
> inability to document it separately (as Jonathan Davis pointed out),
This is an issue shared by named parameters, and for such stuff the
current enums work just fine. Now who is rationalizing? :o)
> is all
> definitely much much more than enough to warrant adding a tried-and-proven
> feature that's become standard in damn near every other modern language.
I'm actually less convinced than before having read your arguments.
Andrei
More information about the Digitalmars-d
mailing list