Problems with receive

Philippe Sigaud philippe.sigaud at gmail.com
Mon Aug 30 13:06:31 PDT 2010


On Mon, Aug 30, 2010 at 12:23, Stanislav Blinov <blinov at loniir.ru> wrote:

>  30.08.2010 3:06, SK wrote:
>
> I encountered this one too and it appears to be a regression in 2.048 that
>> did not occur in 2.047.  It's the same msg[0] vs. msg.field[0] problem, but
>> in concurrency.d itself.  It's a one line patch to make this work.
>>
>> In /usr/include/d/dmd/phobos/std/concurrency.d, change line 384 to look
>> like this:
>>
>> static assert( a1.length != 1 || !is( a1.field[0] == Variant ),
>>
>

> Is that so? I thought ParameterTypeTuple and Tuple are different.
>

You'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.

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.

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's a good idea to put make the if statement a
static if: all other constructs in there are done compile-time, I'd guess.



Philippe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20100830/2d109a0f/attachment.html>


More information about the Digitalmars-d-learn mailing list