I am wondering what to do with error codes.

Posix provides no standards for error code management.

The macros for the code for errno are standard but the values
are not.

There's no standard way for user defined system exits to be managed.

There is, however, an restriction which is really annoying: only the
low 8 bits are significant. This is because waitpid function throws out the
high bits of the process return code and replaces them with an indicator
of how the process exited. The system function call return value is the same.

At the moment felix returns codes like 1,2,3,4 to indicate the exit reason
if there's an error such as an uncaught exception, or whatever the application
code exits with (well, that's because that causes an instant exit).

Unfortunately perror and friends print the error string which has no meaning
if its a felix error. It's non trivial for Felix applications to return an 
error code
conforming to the system's codes since not all OS have the same set
of possible error code (eg OSX, Linux, Windows), and its quite certain
that in many cases the system error codes aren't appropriate.

There's a symbol

        sys_nerr

which is defined in BSD and OSX, telling how many error codes
the system uses. For GNU systems, the _BSD_SOURCE macro has
to be defined I think. The symbol is in stdio.h rather than errno.h.
Not clear if Windows has this.

Unfortunately any codes assigned by Felix could clash with other
libraries. Well, any codes assigned by any libraries could clash
with any libraries. ZMQ for example uses some error codes
and provides its own zmq_perror to decipher them.

This mechanism is not extensible. [The whole errno thing is 
very serious design fault in Posix/C from just about every
point of view]

The only thing I can think of is to assign error codes from 255 down.

--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to