On 6/11/11 1:54 PM, Andrei Alexandrescu wrote:
Consider two statements:

1. "I dislike Flag. It looks ugly to me."

2. "I dislike Flag. Instead I want named arguments."

There is little retort to (1) - it simply counts as a vote against. For
(2) the course of action is to point out the liabilities of changing the
language.

*And*, at least for me, still count it as an (informal) vote against Flag. You wrote about »The point is it [named arguments] would also have disadvantages«, but at the same time, you seem to ignore that using a non-obvious construct all over the standard library adds to perceived the »language complexity« (from the user's perspective) just as well, even more so if opDispatch or other »hacks« are used to beautify the implementation.

Yes, I do think named parameters would be a step forward and we should definitely look into adding them to D. But independently, I don't think that reinventing bool in Phobos is a good idea. How would you explain somebody new to D that, while usually it's »Something.property«, you have to write »Yes.foo« instead of »Foo.yes«? Also, there is the issue of error messages:

---
void foo(Flag!"bar" flag) {}

void main() {
  foo(No.baz);
}
---

leads to

---
Error: function foo (Flag flag) is not callable using argument types (Flag)
Error: cannot implicitly convert expression (opDispatch()) of type Flag to Flag
---

I don't know about you, but I think this is not quite an acceptable error message for mistyping a single character while trying to pass a boolean parameter to some standard library function.

David

Reply via email to