Plot2kill 0.2
dsimcha
dsimcha at yahoo.com
Thu Mar 10 07:17:37 PST 2011
On 3/10/2011 10:03 AM, Kagamin wrote:
> dsimcha Wrote:
>
>> 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();
>
> What do you think about C# object initializers?
> http://msdn.microsoft.com/en-us/library/bb384062.aspx
They work about as well as a with() statement and not as well as method
chaining. The problem is that the toFigure call returns a different
type. The idiomatic way to use Plot2kill is to create a Plot, set all
the Plot properties you need, call toFigure, then set all the Figure
properties you need. (Plot and Figure are distinct because you can have
more than one Plot on a Figure, though you often don't.) Example:
Histogram(someDataSet, 10)
.barColor(getColor(255, 0, 0))
.histType(HistType.Probability)
.toFigure
.title("A Histogram")
.showAsMain();
More information about the Digitalmars-d-announce
mailing list