Re: unsigned int in for loops

2011-02-04 Thread Ellery Newcomer
On 02/04/2011 02:31 PM, Jesse Phillips wrote: Ellery Newcomer Wrote: I think this was the impetus for foreach_reverse, or at least it is one place where it is pretty handy. Don't remember what all there is in D1, but in D2 you could do something like foreach_reverse(i; 0u .. 10u){ // iterates

Re: unsigned int in for loops

2011-02-04 Thread Jonathan M Davis
On Friday 04 February 2011 12:31:06 Jesse Phillips wrote: > Ellery Newcomer Wrote: > > I think this was the impetus for foreach_reverse, or at least it is one > > place where it is pretty handy. Don't remember what all there is in D1, > > but in D2 you could do something like > > > > foreach_rever

Re: unsigned int in for loops

2011-02-04 Thread Jesse Phillips
Ellery Newcomer Wrote: > I think this was the impetus for foreach_reverse, or at least it is one > place where it is pretty handy. Don't remember what all there is in D1, > but in D2 you could do something like > > foreach_reverse(i; 0u .. 10u){ > // iterates over 9,8,7 .. 1,0 > } There was so

Re: unsigned int in for loops

2011-02-04 Thread Ellery Newcomer
ou're stuck with foreach(i; retro(somerange)){ } or tired old for loops On 02/04/2011 10:14 AM, eles wrote: hi everybody, recently i was hit by an old-known programming error, using unsigned int in for loops could get into infinite traps: http://stackoverflow.com/questions/665745/whats-the-b

Re: unsigned int in for loops

2011-02-04 Thread spir
On 02/04/2011 05:14 PM, eles wrote: recently i was hit by an old-known programming error, using unsigned int in for loops could get into infinite traps: http://stackoverflow.com/questions/665745/whats-the-best-way-to-do-a-reverse- for-loop-with-an-unsigned-index Aha! was trapped as well

Re: unsigned int in for loops

2011-02-04 Thread bearophile
eles: > so, i D (1 or 2) is counter-attacking in some way (for example, disabling > implicit casting of (-1) to UINT_MAX). I don't understand your question very well, but at the moment D is doing nearly nothing to avoid this kind of bugs (I have written probably tens of posts on this topic, wit

unsigned int in for loops

2011-02-04 Thread eles
hi everybody, recently i was hit by an old-known programming error, using unsigned int in for loops could get into infinite traps: http://stackoverflow.com/questions/665745/whats-the-best-way-to-do-a-reverse- for-loop-with-an-unsigned-index so, i D (1 or 2) is counter-attacking in some way (for