"Best" way of handling a receive()d message with a class instance.
Meta
jared771 at gmail.com
Thu Jan 23 09:34:20 PST 2014
On Thursday, 23 January 2014 at 16:00:30 UTC, Francesco Cattoglio
wrote:
> Sorry, MY BAD!
>
> You can just write
> auto handler = new Handler;
> receive(&handler.MyFunc);
>
> Somehow when I tried this before it failed to compile, and I
> thought I had to go through loops for achieving this.
It's also useful to mention that in this code here:
auto handler = new Handler;
receiveTimeout( dur!"seconds"(1),
handler.handle
);
The expressions handler.handle is actually invoking the method
handle(). This is due to parentheses being optional in D, which
means that even the function name without the parentheses is a
valid function call. I don't know if you knew that or not, just
in case you didn't.
More information about the Digitalmars-d-learn
mailing list