[cairo] [API] Export region data type

M Joonas Pihlaja jpihlaja at cc.helsinki.fi
Fri Mar 27 22:52:31 PDT 2009


Hey,

Just to chime in on the colour of the bike shed at this late date...

On Sat, 28 Mar 2009, Behdad Esfahbod wrote:

> On 03/27/2009 09:44 PM, Soeren Sandmann wrote:
> 
> > ... If you don't know the C type
> > promotion rules, or if you have repressed them, or if you have
> > forgotten that width is unsigned, it will look like the computer has
> > lost its ability to do arithmetic ...

The benefits of *defined* overflow and underflow behaviour for 
unsigneds, I think, should favour unsigned over signed widths.  
Lately compilers (gcc at least) have started taking advantage of C's 
undefined overflow behaviour to optimise signed integer expressions, 
making it that much more important to make sure your signed 
expressions never overflow.

Regarding the "lost ability", I would argue that it's not so much of a 
problem because the compiler reminds you every time you compare mixed 
sign things, and at the same time you're reminded to check for the 
overflow case.  Unsigneds don't obviate the need for range checks 
either, but as a type unsigned makes those checks far easier to write 
than signed checks.  e.g. "x+y >= x" for addition of unsigneds vs. an 
icky nest of case analysis for signeds.

Cheers,

Joonas


More information about the cairo mailing list