This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Creating Exceptions instead of assertions

Tags: None
(comma "," separated)
MatthiasParzer
Registered Member
Posts
2
Karma
0
OS
The documentation and the posts in this forum state, that error handling in Eigen is consequently based on assertions.
After a short look at the code i brutaly redefined the macros eigen_assert in Core/util/Macros.h and EIGEN_STATIC_ASSERT in Core/util/StaticAssert.h to produce a throw instead of calling abort. A small test with a one-function library worked.

Can it be that easy ???
Why isn't there a precompiler-switch for that ???

I want to build up a small and easy to use Matrix-Library for Common Lisp working with native CL-Arrays. All existing Cl-libraries force the user into its own jungle of conversion between row-major and col-major matrices.
With Eigen, it is surprisingly easy to write some c-functions that write on the already allocated result-array. But i certainly need a return-value in the case of error. A 'library' calling abort() as one and only reaction to any problem seem very strange to me.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Yes that's that simple! Actually we does the same in the unit tests to make sure a given piece of code triggers an assert without aborting.

Our assertions catch *programming* errors, that's why we prefer to use assertions rather than exceptions.
MatthiasParzer
Registered Member
Posts
2
Karma
0
OS
Thank you for the reply.

Cool!!!

A bit of documentation about this feature would not hurt!


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], q.ignora