On 2011-03-05 15:22:15 -0500, "Robert Jacques" <sandf...@jhu.edu> said:
On Sat, 05 Mar 2011 13:42:32 -0500, bearophile
<bearophileh...@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.for...@michelf.com
http://michelf.com/