Initial feedback for std.experimental.image

Vladimir Panteleev via Digitalmars-d digitalmars-d at puremagic.com
Fri Jul 10 18:51:41 PDT 2015


On Friday, 10 July 2015 at 23:21:02 UTC, ketmar wrote:
> On Thu, 09 Jul 2015 23:35:00 +0000, Vladimir Panteleev wrote:
>
>> On Tuesday, 7 July 2015 at 03:39:00 UTC, Rikki Cattermole 
>> wrote:
>>> I've been sold on the unsigned vs signed type issue for and 
>>> only for the x and y coordinates.
>> 
>> The first version of ae.utils.graphics had unsigned 
>> coordinates. As I found out, this was a mistake.
>> 
>> A rule of thumb I discovered is that any numbers you may want 
>> to subtract, you should use signed types. Otherwise, 
>> operations such as drawing an arc with its center point 
>> off-canvas (with negative coordinates) becomes unreasonably 
>> complicated.
>
> giving that `int` and `uint` are freely interchangeable... 
> `uint` is better, as it allows only one bound check in `if`, 
> and without casts. ;-)

That's a poor reason. Optimizing x>=0 && x<100 to an unsigned 
check is such a basic optimization, even DMD can do it.


More information about the Digitalmars-d mailing list