Re:Microsoft open sources C++ REST SDK "Casablanca"
by ksherlock on Tuesday February 26, 2013 @11:50PM
(#5290700)
.then() is just a method. The "anonymous brackets" is a c++11 lambda function. I don't think chaining it like that is common anywhere, yet.
[ Parent
| on HN ]
Re:Microsoft open sources C++ REST SDK "Casablanca"
by apaprocki on Tuesday February 26, 2013 @11:53PM
(#5290714)
The .then() method appears to be something on concurrency::task, which is part of the Microsoft's Parallel Pattern Library. This article says:
"we've started a new project called Casablanca to build a modern C++ library for cloud-based client-server communication, in which all concurrent operations are exposed as PPL tasks."
http://www.drdobbs.com/parallel/improving-futures-and-callba...
Link to Microsoft's C++ committee proposal (N3327): http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n332...
Re:Microsoft open sources C++ REST SDK "Casablanca"
by Figs on Wednesday February 27, 2013 @01:39AM
(#5291028)
I've used that style of programming in some of my hobby projects (mixed with other obvious sequencing operations like wait_until(predicate) and delay(time)) for doing timeline scripting. In my experience, it tended to become a mess when I needed things more complex than linear action sequences (e.g. conditionals, loops, etc. are better suited to a real interpreter).
As far as common uses of chaining for sequencing in C++, the only common use that comes to mind is iostreams operator <<, but that predates lambdas.
Re:Microsoft open sources C++ REST SDK "Casablanca"
by twoodfin on Wednesday February 27, 2013 @12:02AM
(#5290746)
That looks like Microsoft's new "async everywhere" approach to API design. It's probably a pretty good idea in concept, but I hope they don't expect C++ developers to actually write those awful nested lambda .then() blocks for what are conceptually sequential actions.
Re:Microsoft open sources C++ REST SDK "Casablanca"
by marshray on Wednesday February 27, 2013 @12:06AM
(#5290766)
I expect you can define named functions for your "conceptually sequential actions" if you prefer.
Re:Microsoft open sources C++ REST SDK "Casablanca"
by twoodfin on Wednesday February 27, 2013 @12:23AM
(#5290828)
Sure, but is that much better? It reminds me of having to create named struct classes to simulate closures prior to C++11 lambdas. The language syntax just doesn't support that style of programming.
Re:Microsoft open sources C++ REST SDK "Casablanca"
by marshray on Wednesday February 27, 2013 @02:14AM
(#5291099)
So how many languages actually do support this style directly?
The C# async keyword looks pretty clean, just give C++ a decade or so to catch up.
Re:Microsoft open sources C++ REST SDK "Casablanca"
by MichaelGG on Wednesday February 27, 2013 @01:14AM
(#5290967)
Is there a better approach available in C++? In other languages you'd use monads or other special compiler forms that can rewrite sequential looking code into the horrible multi-nested callback/error handling code it needs to be.
Re:Microsoft open sources C++ REST SDK "Casablanca"
by ajasmin on Wednesday February 27, 2013 @01:45AM
(#5291042)
Boost Coroutines perhaps? http://www.boost.org/doc/libs/1_53_0/libs/coroutine/doc/html...