On 2011-06-10 14:52:53 -0400, Robert Clipsham <rob...@octarineparrot.com> said:

On 10/06/2011 19:06, Andrei Alexandrescu wrote:
Ugly is in the eye of the beholder, but I fail to see how the added
punctuation makes Flag!"param".yes significantly more verbose than param
: true.

foo(param: true, otherParam: false);
foo(Flag!"param".yes, Flag!"otherParam".no);

I don't know about you, but I find the former is far more legible. I'd hate to see my code littered with Flag!"something".

I have to say I totally agree with Robert.

I agree with the need for a way to name parameters, but instantiating a pseudo-boolean type from a template for each function parameter is worse than the initial problem. Templates are already a difficult concept to grasp for most people (because they're so abstract), we really don't need to replace every boolean parameter with a template type.


The problem that named parameters are still optional remains. Or we need
to add one extra language feature to specify required named parameters.

void foo(bool param, bool otherParam, bool thisOneIsntRequired = false);

Call it with or without named parameters, two are required, one is not.

foo(otherParam: true, param: false);
foo(true, false);
foo(otherParam: true, param: false, thisOneIsntRequired: true);

And just try to think of the signature for the function above if it was using Flag!

void foo(Flag!"param" param, Flag!"otherParam" otherParam, Flag!"thisOneIsntRequired" thisOneIsntRequired = Flag!"thisOneIsntRequired".no);

Do we really want to expose that in the documentation?

--
Michel Fortin
michel.for...@michelf.com
http://michelf.com/

Reply via email to