Future(s) for D.
Sebastiaan Koppe via Digitalmars-d
digitalmars-d at puremagic.com
Mon Jun 22 08:44:02 PDT 2015
On Saturday, 20 June 2015 at 12:35:11 UTC, weaselcat wrote:
> I recently read this facebook post on their future
> implementation in their Folly library.
>
> https://code.facebook.com/posts/1661982097368498
>
> This made me slightly envious. Thoughts on a D implementation?
After having worked with Observables/RX[1], Futures look kind of
silly to me. I implemented some of them into D (with the help of
fibers).
Recently I made a small program that, on a merged pull-request on
bitbucket, looks if the branch contains fix123, bug-123, etc. and
toggles the ready-to-review status on the issue-tracker.
This is what the code looks like:
```
bitbucketObservable.filter((PullRequest pr)
{
return pr.destination == "master" && pr.type ==
PullRequest.Type.MERGED;
}).map((PullRequest pr)
{
auto r = regex(r"(fix|bug)[\/\-_]*([0-9]+)");
return match(pr.source, r);
}).filter((RegexMatch!(string, ThompsonMatcher) m)
{
return !m.empty();
}).map((RegexMatch!(string, ThompsonMatcher) m)
{
return m.captures[2].to!int;
}).concatMap((int bug)
{
return getCookie.fork(1).setReadyToReview(bug, "updated
from D");
}).subscribe((json)
{
writefln("Response from bontq: %s",json);
},(Exception e)
{
writeln("Error: %s",e);
});
```
[1] https://github.com/Reactive-Extensions/RxJS
More information about the Digitalmars-d
mailing list