Re: Delegate / Error: cannot implicitly convert expression...

2019-06-15 Thread user1234 via Digitalmars-d-learn
On Saturday, 15 June 2019 at 17:42:04 UTC, ag0aep6g wrote: On Saturday, 15 June 2019 at 17:24:45 UTC, user1234 wrote: --- void foo(){writeln(__PRETTY_FUNCTION__);} void main(string[] args) { void delegate() dg; dg.funcptr = dg.ptr = null; // usually a "this" or a frame address

Re: Delegate / Error: cannot implicitly convert expression...

2019-06-15 Thread ag0aep6g via Digitalmars-d-learn
On Saturday, 15 June 2019 at 17:24:45 UTC, user1234 wrote: --- void foo(){writeln(__PRETTY_FUNCTION__);} void main(string[] args) { void delegate() dg; dg.funcptr = dg.ptr = null; // usually a "this" or a frame address dg(); } --- because dg.ptr would be used to retrieve the

Re: Delegate / Error: cannot implicitly convert expression...

2019-06-15 Thread user1234 via Digitalmars-d-learn
On Saturday, 15 June 2019 at 16:34:22 UTC, Robert M. Münch wrote: On 2019-06-15 16:19:23 +, Anonymouse said: By design, I think: "delegate and function objects cannot be mixed. But the standard function std.functional.toDelegate converts a function to a delegate." Your example compiles

Re: Delegate / Error: cannot implicitly convert expression...

2019-06-15 Thread Alex via Digitalmars-d-learn
On Saturday, 15 June 2019 at 16:34:22 UTC, Robert M. Münch wrote: On 2019-06-15 16:19:23 +, Anonymouse said: By design, I think: "delegate and function objects cannot be mixed. But the standard function std.functional.toDelegate converts a function to a delegate." Your example compiles

Re: Delegate / Error: cannot implicitly convert expression...

2019-06-15 Thread Robert M. Münch via Digitalmars-d-learn
On 2019-06-15 16:19:23 +, Anonymouse said: By design, I think: "delegate and function objects cannot be mixed. But the standard function std.functional.toDelegate converts a function to a delegate." Your example compiles if the assignment is changed to dg = toDelegate(); (given

Re: Delegate / Error: cannot implicitly convert expression...

2019-06-15 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 15 June 2019 at 15:54:00 UTC, Robert M. Münch wrote: Why does the follwing code give: Error: cannot implicitly convert expression & myFunc of type void function(int a) to void delegate(int) void myFunc(int a){return;} void main() { void delegate(int) dg; dg = } See: