On Mon, Aug 30, 2010 at 1:21 PM, Stanislav Blinov <span dir="ltr">&lt;<a href="mailto:stanislav.blinov@gmail.com">stanislav.blinov@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

Philippe Sigaud wrote:<br>
<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">
        static assert( a1.length != 1 || !is( a1.field[0] == Variant ),<br>
<br>
 <br>
    Is that so? I thought ParameterTypeTuple and Tuple are different.<br>
<br>
<br></div><div class="im">
You&#39;re right, there are different. ParameterTypeTuple is a type tuple (a bunch of types grouped together, with indexing and length, like an array). Tuple is a struct wrapping a type tuple, which can be exposed through the .field member.<br>


<br>
In the above line, since a1 is a ParameterTypeTuple, it has no .field member. In effect the expression a1.field[0] == Variant has no meaningful type and so is(...) is always false. Hence, || !is(...) is like || true. It disables the second part of the test.<br>


</div></blockquote>
<br>
Thanks, I thought I&#39;m at a loss.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
As for std.concurrency, I never looked at the code before, but the point of receive() seems to do compile-time checking on the matching functions before calling mbox.get( ops ), it&#39;s a good idea to put make the if statement a static if: all other constructs in there are done compile-time, I&#39;d guess.<br>


</blockquote>
<br></div>
Yes, that&#39;s it. And one (final from me :) ) proposed fix for current Phobos would be this:<br>
<br>
The mentioned line (384) of std.concurrency should read:<br>
<br>
static assert( !T[i+1..$].length || a1.length != 1 || !is( a1[0] == Variant ),<br>
<br>
The error occurs currently because function parameter is enforced NOT to be a Variant even for last function in the list (because of i &lt; T.length  on line 382). Thus, assert triggers no matter where in receive() do you insert a Variant handler. Proposed workaround should overcome this by adding additional condition that currently examined handler is not the last one in the list.<br>


<br>
</blockquote></div><br>Thank you guys.  I see that I am too dangerous with .field<br><br>