digitalmars.D - spec: Function types
- Dibyendu Majumdar (3/3) Nov 20 2020 So a type declared using 'function' is actually a function
- Paul Backus (6/9) Nov 20 2020 int fun(int x);
- Dibyendu Majumdar (2/12) Nov 20 2020 thanks
- Dibyendu Majumdar (6/7) Nov 20 2020 pragma(msg, typeof(&fun).stringof);
- Adam D. Ruppe (4/5) Nov 20 2020 If fun is nested it will be a delegate. Only if top-level or
- Dibyendu Majumdar (3/8) Nov 20 2020 I see. Okay thanks
So a type declared using 'function' is actually a function pointer type. What is the type of a function in D?
Nov 20 2020
On Saturday, 21 November 2020 at 00:26:45 UTC, Dibyendu Majumdar wrote:So a type declared using 'function' is actually a function pointer type. What is the type of a function in D?int fun(int x); pragma(msg, typeof(fun).stringof); // int(int x) alias funType = int(int x); static assert(is(funType == typeof(fun)));
Nov 20 2020
On Saturday, 21 November 2020 at 00:42:06 UTC, Paul Backus wrote:On Saturday, 21 November 2020 at 00:26:45 UTC, Dibyendu Majumdar wrote:thanksSo a type declared using 'function' is actually a function pointer type. What is the type of a function in D?int fun(int x); pragma(msg, typeof(fun).stringof); // int(int x) alias funType = int(int x); static assert(is(funType == typeof(fun)));
Nov 20 2020
On Saturday, 21 November 2020 at 00:42:06 UTC, Paul Backus wrote:pragma(msg, typeof(fun).stringof); // int(int x)pragma(msg, typeof(&fun).stringof); prints: int delegate(int x) I was expecting: int function(int x)
Nov 20 2020
On Saturday, 21 November 2020 at 00:51:30 UTC, Dibyendu Majumdar wrote:pragma(msg, typeof(&fun).stringof);If fun is nested it will be a delegate. Only if top-level or static will it be function.
Nov 20 2020
On Saturday, 21 November 2020 at 00:57:10 UTC, Adam D. Ruppe wrote:On Saturday, 21 November 2020 at 00:51:30 UTC, Dibyendu Majumdar wrote:I see. Okay thankspragma(msg, typeof(&fun).stringof);If fun is nested it will be a delegate. Only if top-level or static will it be function.
Nov 20 2020