Re: real simple delegate question.

2017-08-20 Thread angel via Digitalmars-d-learn
On Saturday, 19 August 2017 at 18:33:37 UTC, WhatMeWorry wrote: On Friday, 18 August 2017 at 20:39:38 UTC, angel wrote: On Friday, 18 August 2017 at 02:38:15 UTC, WhatMeForget wrote: [...] This actually appears correct ... The 1-st example: Each call to makeCalculator() increments a static (i

Re: real simple delegate question.

2017-08-19 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 19 August 2017 at 18:33:37 UTC, WhatMeWorry wrote: Or maybe another approach would be to ask, what type is the compiler replacing auto with. If you want to find out compile with `-vcg-ast`

Re: real simple delegate question.

2017-08-19 Thread WhatMeWorry via Digitalmars-d-learn
On Friday, 18 August 2017 at 20:39:38 UTC, angel wrote: On Friday, 18 August 2017 at 02:38:15 UTC, WhatMeForget wrote: [...] This actually appears correct ... The 1-st example: Each call to makeCalculator() increments a static (i.e. shared among all makeCalculator() instances) variable - cont

Re: real simple delegate question.

2017-08-18 Thread angel via Digitalmars-d-learn
On Friday, 18 August 2017 at 02:38:15 UTC, WhatMeForget wrote: Can someone explain what is the difference between the two? Thanks. module gates; import std.stdio; import std.random; alias Calculator = int delegate(int); Calculator makeCalculator() { static int context = 0; int randy

real simple delegate question.

2017-08-17 Thread WhatMeForget via Digitalmars-d-learn
Can someone explain what is the difference between the two? Thanks. module gates; import std.stdio; import std.random; alias Calculator = int delegate(int); Calculator makeCalculator() { static int context = 0; int randy = uniform(1, 7); context++; writeln("context = ", conte