[dmd-concurrency] std.concurrency

Mark Kegel mark.kegel at gmail.com
Wed Feb 24 11:12:10 PST 2010


Yeah, I hadn't really thought out the syntax, but I did want to have
some kind of control flow from within handlers and nothing I'd seen so
far had any examples of how that might work. Since I hadn't seen
anything return a value from a handler I just assumed that the only
thing left would be an exception.

So then if you had a struct-pattern passed to a receive call you are
talking about, what might that look like?

Mark

>Mark, exceptions are not valid form of flow control. This is a fairly well known anti-pattern. Also, the operator overloading of '+' is >generally considered poor design. That said, adding this functionality in a more formalized way would be useful. i.e. giving receive the >explicit ability to handle patterns via struct wrappers by putting something like:

>static if( is( typeof(handeler) == struct ) ) {
>   if( handeler.match(msg) == false )
>       continue;
>}
>handeler( msg );
>break;

>inside the receive message handling body


More information about the dmd-concurrency mailing list