this is almost a workaround for the lack of named parameters

deadalnix deadalnix at gmail.com
Sat Mar 23 12:56:14 PDT 2013


On Saturday, 23 March 2013 at 15:55:36 UTC, John Colvin wrote:
> On Saturday, 23 March 2013 at 15:00:13 UTC, bearophile wrote:
>> foobar:
>>
>>> Code that needs named parameters to be more readable is 
>>> poorly designed code in the first place.
>>
>> Have you used a language where the usage of named arguments is 
>> idiomatic, like Python, Scala or Ada? They are sometimes 
>> useful even for well designed code, like functions with two 
>> arguments.
>>
>> Bye,
>> bearophile
>
> A simple example is matplotlib.pyplot.plot
>
> There are so many possible flags and parameters that can be 
> passed in order to get the exact behaviour you want, but 
> commonly you'll only want a few set for each call. You don't 
> want to have to set all the other preceding parameters, you 
> just want to go e.g. plot(data, linewidth=5)

Can't the monadic style thing do the trick ?

Named!plot.linewidth(5).call(data);

This is doable with actual D using compile time reflection.


More information about the Digitalmars-d mailing list