[cairo] cairo_status_to_string and why I don't like CAIRO_OK

Owen Taylor otaylor at redhat.com
Thu Jun 9 07:19:38 PDT 2005

On Thu, 2005-06-02 at 23:33 -0700, Carl Worth wrote:
> Oh, I had promised "why I don't like CAIRO_OK" earlier, but I ended up
> discarding my original long-winded description when I found I disliked
> the original proposal I had intended to make.
> But now that I've mentioned it, I guess I'll share my current
> thoughts. I've already renamed CAIRO_OK to STATUS_OK which is a more
> accurate name, though not as namespace-friendly.
> The other thing I've never liked about CAIRO_OK is that it introduces
> a synonym of "OK" for "SUCCESS", (and the name CAIRO_OK has always
> sounded to me like it should be doing something like

I'm not going to debate here ... I like CAIRO_OK(), but since it is
*not* being used consistently, I've been meaning to purpose deleting
for a while now.

> which, incidentally, would clash with and provide no benefit[*] over
> directly using the enum that this macro is hiding:
> 	if (status == CAIRO_STATUS_SUCCESS)

I don't think we should write this. If we are frequently writing

 if (status) {

Then we should simply write

 if (!status) {

They are both pretty unreadable until you learn the idiom. 

(t would read better if we were using 'error' rather than 'status', 
but when working with Cairo code, you start saying things like
'return a status' to mean 'return something other than
CAIRO_STATUS_SUCCESS', so it's not completely out-of-the-blue.

> One of the original intentions of CAIRO_OK was to replace uses of "if
> (!status)" when testing for success. I agree that that version is
> abhorrent and shall not appear in the implementation. I think that "if
> (status == CAIRO_STATUS_SUCCESS)" makes a fine replacement for it.

I find that really hard to read and type.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050609/a2360c7b/attachment.pgp

More information about the cairo mailing list