Flag proposal

Steven Schveighoffer schveiguy at yahoo.com
Fri Jun 10 15:14:10 PDT 2011


On Fri, 10 Jun 2011 16:21:59 -0400, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> wrote:

> On 6/10/11 2:30 PM, Jonathan M Davis wrote:
>> On 2011-06-10 09:15, Andrei Alexandrescu wrote:
>>> https://github.com/D-Programming-Language/phobos/pull/94
>>>
>>> Discuss!
>>
>> I do have to admit that as much as I hate the idea of named parameters,  
>> this
>> particular proposal certainly seems to be an argument in favor of  
>> adding them,
>> which would tend to argue against making these changes.
>
> There is general agreement (which includes myself) that a language  
> feature is nicer than Flag,

Yes.

> and that Flag is nicer than the current state of affairs.

No.  Flag!"KeepTerminator".yes is much worse than KeepTerminator.yes.  And  
Flag!"KeepTerminator" keepTerminator is just, horrendous, in documentation  
*or* source.

If the rote creation of boolean enums is a problem, why not a mixin?

template Flag(string name)
{
     mixin("enum " ~ name ~ " : bool { no = false, yes = true }");
}

mixin Flag!"KeepTerminator";

> This is no surprise because a specialized language feature will _always_  
> be better than one built from tools offered within the language. It's  
> like God vs. human.

I think the debate is more about how this solution is a step in the wrong  
direction more than it's not as good as a real solution.

> So the crucial question is whether a language change is warranted.

If the options are Flag or a language solution, the answer is yes.  I'd  
much rather keep things as they are than have Flag!string.

-Steve


More information about the Digitalmars-d mailing list