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 = &foo;
dg.ptr = null; // usually a "this" or a frame address
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 = &foo;
dg.ptr = null; // usually a "this" or a frame address
dg();
}
---
because dg.ptr would be used to retrieve t
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 i
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 i
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(&myFunc); (given ap
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 = &myFunc;
}
S
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 = &myFunc;
}
See: https://run.dlang.io/is/iTYo2L
--
Robert M. Münch
http://www.sa