[MOAB-dev] Discussion on return type of MOAB routines

Jed Brown jed at jedbrown.org
Wed Jan 22 10:43:00 CST 2014


"Wu, Danqing" <wuda at mcs.anl.gov> writes:

> Our concern is more on "Return traditional enum type ErrorCode" VS
> "Return a class object with more information".
>
> The class contains a string type error message in addition to an
> ErrorCode. Returning a class type always has more overhead than
> ErrorCode, with some benchmark tests.

A small POD type should be fast.  You could make some static
thread-local memory for error messages and return a pointer (NULL when
no error).

> What is your preference? Do you know why PETSc still uses ErrorCode
> style? For now, the reason that we might need to return a class
> containing error message is to support some non-error conditions (like
> tag not found)

We never use error handlers/return codes for non-error conditions.  We
define what should happen in that case and have a flag return if the
caller needs to know.

We use error codes because they are simple and portable between
languages.  You can register a custom error handler if you want to
put arbitrary semantics into the error processing system.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/moab-dev/attachments/20140122/9b9ff8b7/attachment.pgp>


More information about the moab-dev mailing list