Flag proposal

KennyTM~ kennytm at gmail.com
Fri Jun 10 12:47:57 PDT 2011


On Jun 11, 11 03:40, Jonathan M Davis wrote:
> On 2011-06-10 12:33, KennyTM~ wrote:
>> On Jun 11, 11 03:30, 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.
>>>
>>> After thinking about it, I'd argue that it would be better to create a
>>> string mixin which created the enums for you instead of using the
>>> template as part of the arguments. e.g.
>>>
>>> mixin(YesNoEnum!"KeepTerminator"));
>>>
>>> Then all of the rest of the code is the same. You'd still use
>>> KeepTerminator.yes and KeepTerminator.no, but we avoided having to create
>>> duplicate enums by hand every time that we want this kind of variable.
>>> So, you still reduce the boilerplate code, but the usage is much less
>>> ugly.
>>>
>>> - Jonathan M Davis
>>
>> The problem is the 'YesNoEnum!"KeepTerminator"' will not be shown along
>> with the DDoc of 'getLine'.
>
> Why would it be? You generally want documentation specific to the enum anyway,
> so that isn't exactly boilerplate. You'd just stick the documentation above
> the mixin. And if you don't want to do that but want it in the documentation
> for the function that uses it (particularly if there's only one - though
> that's often not the case), then just put the documentation in the function's
> documentation. Andrei's current solution does nothing for documentation, and
> arguably makes it worse, because there's no place to put documentation on the
> enum directly if you need to.
>
> - Jonathan M Davis

Please review the previous discussion of why Flag (was YesOrNo) was 
proposed.

http://www.digitalmars.com/d/archives/digitalmars/D/YesOrNo_useful_idiom_helper_or_wanking_134392.html


More information about the Digitalmars-d mailing list