<div class="gmail_quote"><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
instead of a virtual function, but I&#39;ll keep the current design because is<br>
simpler for me (I&#39;m still adapting my brain to all this genericity).<br></blockquote><div><br>What languages are you used to? You seem to do quite well with genericity :)<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<br>
On my current implementation with functions I still have a doubt:<br>
<br>
I&#39;m using template-functions like this one for my callbacks:<br>
<br>
void somefunc(T...) (string regex, T args...) {<br>
    foreach (arg; args) {<br>
        writeln(arg);<br>
    }<br>
}<br></blockquote><div><br>OK, no need for the last &quot;...&quot;  args is already variadic. What you wrote is equivalent  &quot;I want any number of lists of any number of types&quot;. <br>Just use:<br><br>void somefunc(T...)(string regex, T args) {<br>
...<br><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
Then, I write the &quot;selector&quot; for it (in other part of the program) like<br>
this:<br>
<br>
auto t = tuple(&quot;someregex&quot;, &amp;(module.somefunc!(int, double)),tuple(2,3.14));<br></blockquote><div><br>A tuple in a tuple, nice.<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<br>
And then in a third module, I get those selectors and bind them to the<br>
functions like:<br>
<br>
auto selectable = t.field[1];<br>
selectable(t.field[0], t.field[2].expand); // Called!<br>
<br>
With your help, this works like a charm.<br>
<br>
But sometimes there will be no variable arguments to &quot;somefunc&quot; (only the<br>
first string), and in that case I don&#39;t know what would be the correct<br>
syntax to specify that the variable number of arguments will have no args,<br>
both for the template instantiation and for the tuple:<br>
<br>
auto t = tuple(&quot;bla&quot;, &amp;(module.somefunc!(void), tuple(void)); // Fails<br>
auto t = tuple(&quot;bla&quot;, &amp;(module.somefunc!(void, Tuple!(void)()); // Fails too<br></blockquote><div><br>Use tuple(). Or Tuple!()()<br><br>Another possibility could be to write your selector like this:<br><br>
auto t = tuple(&quot;bla&quot;, &amp;(someFun), 2, 3.14);<br><br>That is, the values are not wrapped in a tuple, but directly stored in t.<br>That way, if you want no value, just do:<br>auto t = tuple(&quot;bla&quot;, &amp;(someFun)); // there is an expression tuple of length 0 there.<br>
<br>auto selectable = t[1];<br>selectable(t[0], t.expand[2..$]);<br><br>for now, you cannot directly get a slice from the tuple. You either use expand (an expression tuple, so slicable) or use the Tuple.slice member function (never used it).<br>
<br><br>As to the difference between Tuple!(void) and Tuple!():<br>void is a &#39;valid&#39; type (sort of). It&#39;s just a type that has no value. So Tuple!(void) and Tuple!() are different.<br>You can define the type Tuple!(int, void, int), but you cannot create a value of that type, because the void field cannot have a value.<br>
<br>Tuple!() is a tuple with no field, an empty tuple. You can create it all right. It&#39;s just, its length is zero, and it has no field. <br>If you open it with expand, you get a zero-length typetuple. It&#39;s like an array of length zero: it&#39;s valid, but you cannot access its internal values, because there is none. Other programming languages call this the Unit type, because it&#39;s a (the) type that has only _one_ value, namely Tuple!()().<br>
<br><br>If you ask for the parameter typetuple for a no-arg function, you&#39;ll get a zero-length typetuple:<br><br>int foo() { return 0;}<br>alias ParameterTypeTuple!foo Pfoo;<br>assert(is(Pfoo == TypeTuple!());<br><br>
Pfoo pfoo; pfoo is a tuple of length 0.<br>auto a = foo(pfoo); // we can pass it to a function with no arg.<br><br><br>Philippe<br></div></div>