Re: Setter chaining

2018-05-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/30/18 10:49 AM, DigitalDesigns wrote: Does it sound good? class X {    double x;    @property X foo(double y) { x = y; return this; }    @property X bar(double y) { x = y + 5; return this; } } void main() { X x = new X(); x.foo(3).bar(4); } It sort of emulates UFCS but I'm

Re: Setter chaining

2018-05-30 Thread DigitalDesigns via Digitalmars-d-learn
On Wednesday, 30 May 2018 at 15:46:36 UTC, Steven Schveighoffer wrote: On 5/30/18 10:49 AM, DigitalDesigns wrote: Does it sound good? class X {    double x;    @property X foo(double y) { x = y; return this; }    @property X bar(double y) { x = y + 5; return this; } } void main() { X

Re: Setter chaining

2018-05-30 Thread DigitalDesigns via Digitalmars-d-learn
The above idea can be emulated in code, abiet ugly and useless: https://dpaste.dzfl.pl/bd118bc1910c import std.stdio; struct CT(A,B) { A v; B t; alias v this; B opUnary(string s)() if (s == "~") { return t; } A opUnary(string s)() if