Variadic functions: How to pass another variadic function the variadic args?

2013-08-03 Thread Gabi
void F1(...) { } void F2(...) { //HOW TO pass F1(..) the args we were called with ? }

Re: Variadic functions: How to pass another variadic function the variadic args?

2013-08-03 Thread bearophile
Gabi: //HOW TO pass F1(..) the args we were called with ? import std.stdio; void f1(Args...)(Args args) { foreach (arg; args) arg.writeln; } void f2(Args...)(Args args) { f1(args); } void main() { f2(10, "hello", 1.5); } Bye, bearophile

Re: Variadic functions: How to pass another variadic function the variadic args?

2013-08-03 Thread Ali Çehreli
On 08/03/2013 07:58 AM, bearophile wrote: > Gabi: > >> //HOW TO pass F1(..) the args we were called with ? > > > import std.stdio; > > void f1(Args...)(Args args) { > foreach (arg; args) > arg.writeln; Would you expect the following two lines behave the same? writeln(args);

Re: Variadic functions: How to pass another variadic function the variadic args?

2013-08-03 Thread monarch_dodra
On Saturday, 3 August 2013 at 15:10:20 UTC, Ali Çehreli wrote: On 08/03/2013 07:58 AM, bearophile wrote: > Gabi: > >> //HOW TO pass F1(..) the args we were called with ? > > > import std.stdio; > > void f1(Args...)(Args args) { > foreach (arg; args) > arg.writeln; Would you expe

Re: Variadic functions: How to pass another variadic function the variadic args?

2013-08-03 Thread bearophile
monarch_dodra: writefln("%s", 10, "hello", 1.5); => 10 According to a recent discussion with Andrei, that's (thankfully) going to become a run-time exception: http://d.puremagic.com/issues/show_bug.cgi?id=4927 Bye, bearophile

Re: Variadic functions: How to pass another variadic function the variadic args?

2013-08-03 Thread Gabi
On Saturday, 3 August 2013 at 14:58:49 UTC, bearophile wrote: Gabi: //HOW TO pass F1(..) the args we were called with ? import std.stdio; void f1(Args...)(Args args) { foreach (arg; args) arg.writeln; } void f2(Args...)(Args args) { f1(args); } void main() { f2(10, "h

Re: Variadic functions: How to pass another variadic function the variadic args?

2013-08-03 Thread monarch_dodra
On Saturday, 3 August 2013 at 16:57:41 UTC, Gabi wrote: On Saturday, 3 August 2013 at 14:58:49 UTC, bearophile wrote: Gabi: //HOW TO pass F1(..) the args we were called with ? import std.stdio; void f1(Args...)(Args args) { foreach (arg; args) arg.writeln; } void f2(Args...)(Arg

Re: Variadic functions: How to pass another variadic function the variadic args?

2013-08-03 Thread Gabi
On Saturday, 3 August 2013 at 18:48:17 UTC, monarch_dodra wrote: On Saturday, 3 August 2013 at 16:57:41 UTC, Gabi wrote: On Saturday, 3 August 2013 at 14:58:49 UTC, bearophile wrote: Gabi: //HOW TO pass F1(..) the args we were called with ? import std.stdio; void f1(Args...)(Args args) {

Re: Variadic functions: How to pass another variadic function the variadic args?

2013-08-03 Thread bearophile
monarch_dodra: My guess though, is that it's the same syntax as in C? Use a straight up elispis: void foo(...). Note that you *can't* extract the types from the vararg unless you *guess* them from an alternative source (for example, "fmt" in the printf function) Also, importing "core.vara

Re: Variadic functions: How to pass another variadic function the variadic args?

2013-08-03 Thread monarch_dodra
On Saturday, 3 August 2013 at 19:12:40 UTC, bearophile wrote: monarch_dodra: My guess though, is that it's the same syntax as in C? Use a straight up elispis: void foo(...). Note that you *can't* extract the types from the vararg unless you *guess* them from an alternative source (for examp

Re: Variadic functions: How to pass another variadic function the variadic args?

2013-08-04 Thread Ali Çehreli
On 08/03/2013 09:05 AM, monarch_dodra wrote: > On Saturday, 3 August 2013 at 15:10:20 UTC, Ali Çehreli wrote: >> On 08/03/2013 07:58 AM, bearophile wrote: >> >> > Gabi: >> > >> >> //HOW TO pass F1(..) the args we were called with ? >> > >> > >> > import std.stdio; >> > >> > void f1(Args...)(Arg

Re: Variadic functions: How to pass another variadic function the variadic args?

2013-08-04 Thread monarch_dodra
On Sunday, 4 August 2013 at 15:29:48 UTC, Ali Çehreli wrote: On 08/03/2013 09:05 AM, monarch_dodra wrote: > On Saturday, 3 August 2013 at 15:10:20 UTC, Ali Çehreli wrote: >> On 08/03/2013 07:58 AM, bearophile wrote: >> >> > Gabi: >> > >> >> //HOW TO pass F1(..) the args we were called with ? >