Signed-unsigned comparisons in Phobos

Jacob Carlborg doob at me.com
Fri Aug 12 11:36:32 PDT 2011


On 2011-08-12 20:26, Simen Kjaeraas wrote:
> On Fri, 12 Aug 2011 19:19:09 +0200, Marco Leise <Marco.Leise at gmx.de> wrote:
>> This way it is actually fun to cripple the for loop, yay. Still if
>> people started to argue that it is a bad idea to modify variables in
>> the condition I'd silently agree. So a look at "foreach_reverse (i;
>> 0..x.length) {...}" might be worth it. I guess after a while I will
>> get used to it. It even reminds me of the Pascal "for"-syntax a bit,
>> which is "for i := 0 to 9 do ...". It has no receipt for the reverse
>> zero-length array loop though as far as I know.
>
> Pascal has downto:
>
> for i := 9 downto 0 do ...

If D had uniform function call syntax and good looking delegate literals 
we could do this:

0.upto(9 ; i) {
     // do something with i
}

9.downto(0 ; i) {
     // do something with i
}

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list