-
-
Notifications
You must be signed in to change notification settings - Fork 740
Added Flag template #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Acted on suggestions. |
I must add this makes me particularly proud of eliminating parens from one-argument templates :o). |
I'm not really sure what to think about this – not that the implementation wouldn't be nice, but in my opinion, introducing named parameters would be the better solution to this problem. I vaguely recall a discussion on the topic, was there any reason for not adopting them? Even C# has them now, and in my eyes they would make a hell lot of sense for D as well… |
It's a bit more verbose than the current solution (e.g. As for named arguments, this can work with them just fine, though if we get named arguments at a later date and decide that we want to switch everything to |
I find it a little surprising to see something named "Flag" be simply a boolean in disguise. I'd have expected it to be more generic, something letting you to put multiple flags in a single value for instance, as you can find in many APIs. Also, I agree with klickverbot: named parameters would be much better for this. The goal seems to be to compensate for a lack of expressiveness in the language, but this solution being limited to booleans and having a redundancy at the definition site ( |
Michel: it's "flag", not "flags". I'll answer the other point in the newsgroup. |
If this goes in, we really need to do something about the quality of error messages: void foo(Flag!"bar" bar, Flag!"baz" baz) {}
void main() {
foo(Yes.bar, No.bar);
}
|
Good point. Once the compiler improves these messages, other cases will be improved too. |
Too controversial. |
.gitignore Makefile
In order to make Phobos calls self-explanatory, we have a lot of small enums defining "no" and "yes". This request systematizes that approach by making it easy to use such flags without needing to define them. Furthermore, code outside Phobos can define and use flags of their own.