Flag proposal
Lars T. Kyllingstad
public at kyllingen.NOSPAMnet
Fri Jun 10 23:28:14 PDT 2011
On Fri, 10 Jun 2011 18:16:14 -0500, Andrei Alexandrescu wrote:
> On 6/10/11 6:03 PM, Dmitry Olshansky wrote:
>> On 11.06.2011 0:58, Andrei Alexandrescu wrote:
>>> On 6/10/11 3:30 PM, Nick Sabalausky wrote:
>>>> I really see Flag more as a way to try to rationalize avoiding adding
>>>> named
>>>> parameters to the language.
>>>
>>> There are fights that I believe are important and others that I think
>>> are less so. I find name parameters nice to have but more in the
>>> second category. There's just so much stuff that's more important.
>>>
>>>> And yes, the legibility of "foo(Flag!"param".yes,
>>>> Flag!"otherParam".no);",
>>>
>>> Fair point. I figured this should be easier:
>>>
>>> foo(yes!"param", no!"otherParam");
>>
>> I think this looks not half bad and does not require change in the
>> language.
>> Still yes.param and no.param might be easier on the eyes, though IMO it
>> should look more like just param and no.param. e.g.
>> StopWatch(autoStart);
>> StopWatch(no!autoStart); // or no.autoStart
>
> Ask, and ye shall receive.
>
> https://github.com/andralex/phobos/
commit/801ccc96ce56827cd0d0b608895269bdccba4330
I'm sold. :)
To add my 2 cents to the "named arguments" debate, I can't believe people
are still asking for this. At this point in D's development, adding such
would be a major language change, and there really shouldn't be any more
of those. I mean, D2 supposedly went stable almost a year ago! If/when
work starts on D3, we can get back to it.
In the mean time, I think Flag!"param" with the new Yes/No types nicely
solves a common case of code duplication in Phobos. It is not, nor do I
think Andrei intended it to be, a general attempt to emulate named
parameters.
-Lars
More information about the Digitalmars-d
mailing list