Re: closures + struct: Error: forward reference to inferred return type of function call

2020-12-15 Thread ddcovery via Digitalmars-d-learn
On Tuesday, 15 December 2020 at 19:53:33 UTC, Q. Schroll wrote: On Monday, 14 December 2020 at 14:39:14 UTC, ddcovery wrote: On Monday, 14 December 2020 at 12:22:26 UTC, ddcovery wrote: int opCmp(Number other){ return _value - other.value; }; Correction: bool opEquals(Number

Re: closures + struct: Error: forward reference to inferred return type of function call

2020-12-15 Thread Q. Schroll via Digitalmars-d-learn
On Monday, 14 December 2020 at 14:39:14 UTC, ddcovery wrote: On Monday, 14 December 2020 at 12:22:26 UTC, ddcovery wrote: int opCmp(Number other){ return _value - other.value; }; Correction: bool opEquals(Number other){ return _value == other.value; }; You could just give

Re: closures + struct: Error: forward reference to inferred return type of function call

2020-12-14 Thread ddcovery via Digitalmars-d-learn
On Monday, 14 December 2020 at 12:22:26 UTC, ddcovery wrote: int opCmp(Number other){ return _value - other.value; }; Correction: bool opEquals(Number other){ return _value == other.value; };

closures + struct: Error: forward reference to inferred return type of function call

2020-12-14 Thread ddcovery via Digitalmars-d-learn
In this example, I try to use D Voldemore (fantastic) functionallity to implement a pattern usually used in javascript. Basically, a function closure represents the state, and the methods to access this state are returned in the form of union (union has not state itself). void main(){