Serving the Quantitative Finance Community

  • 1
  • 2
  • 3
  • 4
  • 5
  • 10
 
User avatar
Cuchulainn
Posts: 20203
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- generic programming

December 14th, 2012, 3:00 pm

Say you're in the kitchen in front of the refrigerator, thinking about a sandwich. You take a continuation right there and stick it in your pocket. Then you get some turkey and bread out of the refrigerator and make yourself a sandwich, which is now sitting on the counter. You invoke the continuation in your pocket, and you find yourself standing in front of the refrigerator again, thinking about a sandwich. But fortunately, there's a sandwich on the counter, and all the materials used to make it are gone. So you eat it.
 
User avatar
Traden4Alpha
Posts: 3300
Joined: September 20th, 2002, 8:30 pm

C++ quiz --- generic programming

December 14th, 2012, 3:22 pm

QuoteOriginally posted by: CuchulainnSay you're in the kitchen in front of the refrigerator, thinking about a sandwich. You take a continuation right there and stick it in your pocket. Then you get some turkey and bread out of the refrigerator and make yourself a sandwich, which is now sitting on the counter. You invoke the continuation in your pocket, and you find yourself standing in front of the refrigerator again, thinking about a sandwich. But fortunately, there's a sandwich on the counter, and all the materials used to make it are gone. So you eat it.Bread-safe computing, what?
 
User avatar
Cuchulainn
Posts: 20203
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- generic programming

December 14th, 2012, 3:34 pm

QuoteOriginally posted by: Traden4AlphaQuoteOriginally posted by: CuchulainnSay you're in the kitchen in front of the refrigerator, thinking about a sandwich. You take a continuation right there and stick it in your pocket. Then you get some turkey and bread out of the refrigerator and make yourself a sandwich, which is now sitting on the counter. You invoke the continuation in your pocket, and you find yourself standing in front of the refrigerator again, thinking about a sandwich. But fortunately, there's a sandwich on the counter, and all the materials used to make it are gone. So you eat it.Bread-safe computing, what?Next time I want my bread buttered on both sides and no turkey (poor animals), give me a chicken any day. Since everything is stateless there are no race conditions. So, with these generic constructs I can add continuation semantics into sequential programs using C++. So, you could have a graph whose nodes are updated with turkey and mayonaise.
Last edited by Cuchulainn on December 14th, 2012, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20203
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- generic programming

December 17th, 2012, 12:09 pm

Q. Instead of abstract classes with pure functions to implement interfaces, we can put a bunch of std::function into a struct?(?) No virtual functions needed.
Last edited by Cuchulainn on December 16th, 2012, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20203
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- generic programming

December 18th, 2012, 12:31 pm

OK?
Last edited by Cuchulainn on December 17th, 2012, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20203
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- generic programming

April 24th, 2013, 12:37 pm

Q: how can we define multi-cast std::function natively in C++ 11? With boost::signals it is possible but I need 2 separate overloaded functions.(C# calls them multicast delegates)
Last edited by Cuchulainn on April 23rd, 2013, 10:00 pm, edited 1 time in total.
 
User avatar
Polter
Posts: 1
Joined: April 29th, 2008, 4:55 pm

C++ quiz --- generic programming

April 24th, 2013, 1:14 pm

http://bit.ly/15GUR4s :-)For instance, http://www.codeproject.com/Articles/183 ... c11/What's wrong with Boost.Signals?Signals and events/multicast delegates seem to be solving the same problem:"The C# equivalent of a Qt signal is a 'event'. To use events you need to declare a multicast delegate type. "// http://blogs.kde.org/2004/01/11/combini ... atesevents
Last edited by Polter on April 23rd, 2013, 10:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20203
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- generic programming

April 24th, 2013, 1:45 pm

I really like Boost Signals, no problem. But std::fucnction would be the ultimate function wrapper. Signals in C++ 14? Somehow assigning std f = signal does not work.Google is useful for nasty bugs and also to a lesser extent the new developments, but then there are so many solutions (not all of which are what I need and it takes time to read/fathom) and lots of text. A fast, non-standard solution is maybe needed but is less attractive than native C++. I know exactly the problem I want to solve and try a number of alternatives until the compiler refuses to do what I want.std::function is less "event-inherent" than signals. We can always use list<std::function<...>> and then come variadic templates.
Last edited by Cuchulainn on April 23rd, 2013, 10:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20203
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- generic programming

April 25th, 2013, 9:39 am

QuoteOriginally posted by: outrunWhat about parallel multicast?Some languages have a "For each" construct without any specific order guarantees, ideal for parallel execution.PLINQ
 
User avatar
Cuchulainn
Posts: 20203
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- generic programming

April 25th, 2013, 10:42 am

QuoteOriginally posted by: outrunQuoteOriginally posted by: CuchulainnQuoteOriginally posted by: outrunWhat about parallel multicast?Some languages have a "For each" construct without any specific order guarantees, ideal for parallel execution.PLINQExactly!Any similar devs in C++ (i reckon on top of STL and Boost), in the vein of boost::multiindex?
Last edited by Cuchulainn on April 24th, 2013, 10:00 pm, edited 1 time in total.
 
User avatar
Polter
Posts: 1
Joined: April 29th, 2008, 4:55 pm

C++ quiz --- generic programming

April 26th, 2013, 1:14 am

QuoteOriginally posted by: outrunWhat about parallel multicast?Some languages have a "For each" construct without any specific order guarantees, ideal for parallel execution.This has been recently released:
particular, multifunction_node has caught my attention:http://threadingbuildingblocks.org/docs ... de_cls.htm Of course, the usual parallel algorithms are still there as well: http://threadingbuildingblocks.org/docs ... rithms.htm
Last edited by Polter on April 25th, 2013, 10:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20203
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

C++ quiz --- generic programming

April 26th, 2013, 5:27 am

On a related issue, how to design large, potentially concurrent systems? In any case, task and/or data decomposition is probably indispensible and graph theory algorithms.BTW in general, do you think it is possible to parallelise existing C/C++ code? In many cases I think it is almost impossible (data flow and OO encapsulation are incompatible). Bottom up approach not so useful now.PPL ~ TBB? TPLThere are a lot of commonality between all these libraries (cf. C# TPL) and are abstracted here. AFAIK the PPL and TBB code are the same.
Last edited by Cuchulainn on April 25th, 2013, 10:00 pm, edited 1 time in total.