On Friday, 27 October 2017 at 06:45:03 UTC, Jacob Carlborg wrote:
On 2017-10-25 16:58, jmh530 wrote:
You're passing the function arguments as template parameters.
Usually you want them to be able to be passed at run-time.
No problem:
$ cat main.d
import std.stdio;
void foo(args...)()
{
writeln(args);
}
void main(string[] args)
{
foo!(args);
}
$ dmd main.d
$ ./main foo bar
["./main", "foo", "bar"]
Color me surprised. Even the below compiles and runs without error
import std.stdio;
void foo(args...)()
{
writeln(args);
}
void main()
{
int x1 = 1;
int x2 = x1 + 1;
foo!(x1, x2);
}