Re: Calling arbitrary functions at runtime?

2016-12-11 Thread Kevin Balbas via Digitalmars-d-learn
On Sunday, 11 December 2016 at 22:18:02 UTC, Adam D. Ruppe wrote: On Sunday, 11 December 2016 at 22:00:27 UTC, Kevin Balbas wrote: Basically, I need some way to turn an array of strings into an argument list at runtime. Is this possible? Write (or generate) a helper function that loops over t

Re: Calling arbitrary functions at runtime?

2016-12-11 Thread ketmar via Digitalmars-d-learn
import std.traits; import std.stdio; alias FDg = void delegate (string args); FDg[string] cmdlist; void register(DG) (string name, DG dg) if (isCallable!DG) { cmdlist[name] = delegate (string args) { import std.array : split; import std.conv : to; alias Args = Parameters!DG;

Re: Calling arbitrary functions at runtime?

2016-12-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 11 December 2016 at 22:00:27 UTC, Kevin Balbas wrote: Basically, I need some way to turn an array of strings into an argument list at runtime. Is this possible? Write (or generate) a helper function that loops over the Parameters!Func tuple and populates it from the strings. Call t

Calling arbitrary functions at runtime?

2016-12-11 Thread Kevin Balbas via Digitalmars-d-learn
I'm writing a system to register functions to be called at runtime. With zero-argument functions, it works fine. However, I run into a problem with functions that take arguments. This is the relevant code I started with (zero-argument version): mixin template CommandSystemRegister(string s =