<div class="gmail_quote">On Sun, Sep 19, 2010 at 03:43, Juanjo Alvarez <span dir="ltr">&lt;<a href="mailto:juanjux@gmail.com">juanjux@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
&gt; enum string code = &quot;auto deleg = &amp;&quot; ~ className ~ &quot;.&quot; ~ methodName ~ &quot;;&quot;;<br><div class="im">
&gt; // auto deleg = &amp;MyClass.mymethod;<br>
&gt; mixin(code); // created deleg, you&#39;re good to go.<br>
<br>
</div>I tried it and worked like a charm (but I&#39;ve changed my code so instead of<br>
two strings to class + method, a fully qualified non member function address<br>
is used so I have a little more flexibility).<br></blockquote><div><br>String mixins are quite powerful, if a bit clunky at times.<br><br>See also __traits(getMember, ...)<br><a href="http://digitalmars.com/d/2.0/traits.html">http://digitalmars.com/d/2.0/traits.html</a>   (look for getMember)<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;"><div class="im"><br>
</div><div class="im">&gt; Use the .field or .expand alias, exposed by Tuple!() to get a direct<br>
&gt; access to the internal expression tuple.<br>
&gt;<br>
&gt; f(tup.expand); // cracks tup open<br>
<br>
</div>Now, that is exactly what I wanted. It even works if the function has<br>
aditional arguments before the expanded tuple one&#39;s:<br>
<br>
//<br>
void f(int a, int b, double c) {<br>
   writeln(a); writeln(b); writeln(c);<br>
<div class="im">}<br></div></blockquote><div> </div><div><br>Yes, because tuple.expand is directly the expression tuple stored inside Tuple!(...)<br>When you have a typetuple in a template, like this:<br><br>template List(T...)<br>
{<br>}<br><br>The T... part is a typetuple: an array of types, if you wish. You can get its length, index it, slice it, iterate on it, etc.<br>You can have a variable with this strange &#39;type&#39; and also get its length, etc.<br>
<br>template List(T...)<br>{<br>    T t;<br>}<br><br>t is an expression tuple. std.typecons.Tuple is nothing more than the preceding List!(...), with a few more functionalities.<br>So, something interesting is that when you do tup.expand, you obtain a bunch of values of different types, all perfectly individually typed and usable. You can get one by indexing, slice it, etc.<br>
<br>So, given your new f, you can even do:<br><br><div class="im">

auto tup = tuple(42, 3.14);<br>
</div>f(tup.expand[0], 1, tup.expand[1]);<br><br>Though in this particular case, it&#39;s cleaner to do:<br><br>f(tup[0], 1, tup[1]); <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;">

Wonderful. I wish it was better documented on<br>
<a href="http://digitalmars.com/d/2.0/phobos/std_typecons.html" target="_blank">http://digitalmars.com/d/2.0/phobos/std_typecons.html</a><br>
<div class="im"><br></div></blockquote><div><br>Yes, typecons.Tuple has lot of nifty things going for it, but there are not all documented.<br>You can open a bug/enhancement request at <a href="http://d.puremagic.com/issues/">http://d.puremagic.com/issues/</a><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;"><div class="im"><br>
</div>Nice to know. I got you excellent explanation.<br>
<br>
Thanks * 100,<br>
<br></blockquote><div><br>My pleasure,<br><br>Philippe <br></div></div>