Re: [dev] stderr: unnecessary?

From: pancake <>
Date: Fri, 11 Jun 2010 18:19:18 +0200

On 06/11/10 15:21, Moritz Wilhelmy wrote:
> I know you're trolling, but I already thought about why 0 indicates success.
> Point is, it actually makes sense because you usually have either success or
> failure, and in case of failure, you might need another indicator to return the
> nature of the failure.
mixing data and errors in the same value is the source of many
the programming errors and security bugs. this is why NULL
exists, or -1 is used.

In UNIX those 'exceptions' are used in a very smart way, but for
coherence, it's good that a single app, or system follows a single
rules to propagate data and errors.

In GObject, exceptions, or errors are passed as reference in an
argument, so the return value can be used without restrictions:

for example:

    unsigned int read(int fd, ref char *buf, unsigned int buf_len,
GError **err);

(yeah, thats a silly example, but it allows you to make reads bigger
than 31 bits
without having to check for the return value) In other situations it is good
to handle errors in this way, but thinking on some restrictions allows
you to mix error values and data in the same pipe.

Received on Fri Jun 11 2010 - 16:19:18 UTC

This archive was generated by hypermail 2.2.0 : Fri Jun 11 2010 - 16:24:03 UTC