Plot2kill 0.2
Michel Fortin
michel.fortin at michelf.com
Sat Mar 5 12:30:58 PST 2011
On 2011-03-05 15:22:15 -0500, "Robert Jacques" <sandford at jhu.edu> said:
> On Sat, 05 Mar 2011 13:42:32 -0500, bearophile
> <bearophileHUGS at lycos.com> wrote:
>
>> dsimcha:
>>
>>> I've done some major updating of my Plot2kill plotting library lately,
>>
>> I see code that wants named arguments :-)
>>
>> 65 auto sleepinessFig = Figure(sleepinessPlot)
>> 66 .title("Sleepiness Survey")
>> 67 .yLabel("Sleepiness Rating")
>> 68 .xLabel("Activity")
>> 69 .legendLocation(LegendLocation.right)
>> 70 .horizontalGrid(true)
>> 71 .xTickLabels(
>> 72 iota(3),
>> 73 ["In Meeting", "On Phone", "Coding"]
>> 74 );
>>
>> Bye,
>> bearophile
>
> Why? Each of those arguments should be able to be set after creation.
> So given DRY principals, method chaining is the way to go. Besides,
> Figure takes a variable number of plot arguments, which means you
> couldn't support default arguments (at least with the current syntax).
The funny thing is what will happen to this code once @property is
properly implemented? I think this is a cleaner way to write the above,
and it'll work with @property:
auto sleepinessFig = Figure(sleepinessPlot);
with (sleepinessFig) {
title = "Sleepiness Survey";
yLabel = "Seeliness Rating";
xLabel = "Activity";
legendLocation = LegendLocation.right;
horizontalGrid = true;
xTickLabels(iota(3), ["In meeting, "On Phone", "Coding]);
}
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d-announce
mailing list