[cairo] return value of _cairo_composite_rectangles_intersect()

Enrico Weigelt, metux IT consult enrico.weigelt at gr13.net
Sat Dec 19 10:06:54 PST 2015


On 19.12.2015 11:08, Uli Schlachter wrote:

> I think that the general convention is to return status codes
> everywhere. Callers then just check for success and otherwise then
> return the status code to their callers etc until the "top function"
> is hit and does something with this.

Yeah, but then the caller would have consider any possible return value,
because *theorectically* (by definition of the return type) it *could*
return any enum value.

If C had constrainted subtypes, all of this would be pretty easy - we
could let those functions return a subtype, which is constrainted to
exactly the allowed values, so the compiler could check for that.

> So yeah, I guess a bool would be easier, but a status code is more consistent
> with other functions which can return status codes (plus this means that callers
> don't have to "invent" a status code if some function fails).

Hmm, I don't think it's really consistent. Okay, you can simply pass the
value up in the call hierarchy - but is that really so helpful ?
In those, we're essentially branching between success and fail, and the
fail case, there is only one possible fail reason.

> However, this is all just a matter of taste and if some code has good reasons to
> do something else, why not?

Yeah, and I wouldn't underestimate the importance of good taste. I've
learned that a large part of good software development happens on an
subconcious / emotional level (at least for me, personally :p)


--mtx

--
Enrico Weigelt,
metux IT consulting
+49-151-27565287


More information about the cairo mailing list