Re: Retreive method given object, name and arguments

2016-08-11 Thread ketmar via Digitalmars-d-learn
On Thursday, 11 August 2016 at 20:27:51 UTC, Michael Coulombe wrote: here is something for you to play with: import std.stdio; enum CallAllowed0; enum CallAllowed1; struct S { @CallAllowed0 void foo () { writeln("foo()"); } @CallAllowed1 void foo (int n) { writeln("foo(", n, ")"); } }

Re: Retreive method given object, name and arguments

2016-08-11 Thread ketmar via Digitalmars-d-learn
On Thursday, 11 August 2016 at 20:41:33 UTC, ketmar wrote: ah, my bad, i missed UDA part of the question. sorry. ;-)

Re: Retreive method given object, name and arguments

2016-08-11 Thread ketmar via Digitalmars-d-learn
On Thursday, 11 August 2016 at 20:27:51 UTC, Michael Coulombe wrote: import std.stdio; struct S { void foo () { writeln("foo()"); } void foo (int n) { writeln("foo(", n, ")"); } } auto doit(string methodName, C, Args...) (C c, Args args) { static if (is(typeof(mixin("c."~methodName~"(a

Re: Retreive method given object, name and arguments

2016-08-11 Thread Lodovico Giaretta via Digitalmars-d-learn
On Thursday, 11 August 2016 at 20:27:51 UTC, Michael Coulombe wrote: Is there a way to implement "getSymbolOfCall" and "getDelegateOfCall" such that doit is functionally equivalent to calling the method directly? auto doit(C, string methodName, Args...)(C c, Args args) { alias methodSymbol

Retreive method given object, name and arguments

2016-08-11 Thread Michael Coulombe via Digitalmars-d-learn
Is there a way to implement "getSymbolOfCall" and "getDelegateOfCall" such that doit is functionally equivalent to calling the method directly? auto doit(C, string methodName, Args...)(C c, Args args) { alias methodSymbol = getSymbolOfCall!(c, methodName, Args); pragma(msg, hasUDA!(meth