SERVING THE QUANTITATIVE FINANCE COMMUNITY

 
User avatar
Cuchulainn
Posts: 61563
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Exception handling in C++

November 25th, 2015, 3:04 pm

Here's a customizable and non-intrusive approach using Boost signals2.I think it's better to think in terms of software contracts instead of exceptions. I don't what the best choice is in general, which is OK I suppose because no on else knows either (maybe Bertrand Meyer?)
Last edited by Cuchulainn on November 24th, 2015, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
Cuchulainn
Posts: 61563
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Exception handling in C++

November 25th, 2015, 4:20 pm

QuoteOriginally posted by: outrunMy preference is to never make something runtime configurable if you don't need it to be. its less expressive (type erasure) and had overhead. So I would use template and policies classes... But without requirements there is no good or bad!It is very easy to make requirements. But that's not the point RT vs CT.It's a design by contract problem. Here is my requirement "I want to use a numerical algorithm AND I do all the checking myself (my responsibility), not the code that the algorithm implements.' I think that is clear.In your code it would be:
Last edited by Cuchulainn on November 24th, 2015, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
Cuchulainn
Posts: 61563
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Exception handling in C++

November 25th, 2015, 5:15 pm

QuoteOriginally posted by: outrunYes, that's what the code frament I posted a couple of posts ago does!Using structs. Which are inflexible. My code needs no T.In this case they are being used as surrogate for free functions. So, a free function would just be as good. (IMO)
Last edited by Cuchulainn on November 24th, 2015, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
Cuchulainn
Posts: 61563
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Exception handling in C++

November 25th, 2015, 5:58 pm

QuoteOriginally posted by: outrunBecause of CT it's able to do "nada" unlike RT, that was a requirement you liked..It's not a question of liking. Let me phrase it differently (and take me out of the discussion). Let's say we have 4 solutions to this problem, thus1234and a number of applications with different responsibilitiesA very staticB ..C very dynamicWhich solution is 'best' for each application?
Last edited by Cuchulainn on November 24th, 2015, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
Cuchulainn
Posts: 61563
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Exception handling in C++

November 25th, 2015, 7:03 pm

yes, you are bingo! I think problem solved. Congrats.Now it is possible to have hardboiled and rt steroids. N.B. Nice thing is the MySqrtOnSteroids<T>() can be called without having to give a parameter! Clever compiler.BTW an empty signals is ~ 300 times slower than a noop. It is only useful when algo >> check. Compare it to driving your Ferrari in 30 km/hour zone. But in the desert it is blistering fast.stop
Last edited by Cuchulainn on November 24th, 2015, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
Cuchulainn
Posts: 61563
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Exception handling in C++

November 25th, 2015, 8:35 pm

C++14 generic lambda fried steroidsEven nicer?
Last edited by Cuchulainn on November 24th, 2015, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
Cuchulainn
Posts: 61563
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Exception handling in C++

November 26th, 2015, 10:47 am

Yes, the code evolved nicely! Good feedback.Somehow I feel that a C++ state machine would be good, but not for all kinds of applications.This code summarized the chain of events. I would like to share it so people can see the full story as it were:
Last edited by Cuchulainn on November 25th, 2015, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
Polter
Posts: 2526
Joined: April 29th, 2008, 4:55 pm

Exception handling in C++

December 2nd, 2015, 3:55 pm

P0166R0: Three interesting questions about contractshttp://www.open-std.org/JTC1/SC22/WG21/docs/pa ... 0166r0.pdf
ABOUT WILMOTT

PW by JB

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...


Twitter LinkedIn Instagram

JOBS BOARD

JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...


GZIP: On