Plot2kill 0.2
dsimcha
dsimcha at yahoo.com
Sat Mar 5 13:30:06 PST 2011
This is why I don't want to see @property fully implemented. Ever. I
love this method chaining stuff and you can pry it out of my cold, dead
hands. There was a discussion about this a long time ago when I was
writing the first version of Plot2kill that gave me the impression that
@property was to be used for disambiguation only. (See
http://www.digitalmars.com/d/archives/digitalmars/D/Overloading_property_vs._non-property_113421.html
.)
The problem with the with statement idea is that you still need to
declare the variable. I often throw up quick anonymous plots with
anonymous Figure objects, like:
Histogram(someDataSet).toFigure
.title("A Title")
.xLabel("Stuff")
.showAsMain();
I consider the ability to have the same function be called with both
syntaxes to be a beautiful thing, not a defect. If @property is ever
fully implemented, I'll nag for an @optionalproperty tag to bring back
this **feature**.
On 3/5/2011 3:30 PM, Michel Fortin wrote:
> 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]);
> }
>
More information about the Digitalmars-d-announce
mailing list