Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-08 Thread Timon Gehr
On 03/08/2012 03:39 AM, Ary Manzana wrote: On 3/7/12 2:28 AM, Ali Çehreli wrote: On 03/06/2012 09:11 PM, ixid wrote: I'm writing my first basic algorithms, this one is merge sort. This version throws an exception when array.length - setSize is negative (which should be fine, the rest of my

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread James Miller
On 7 March 2012 19:30, H. S. Teoh hst...@quickfur.ath.cx wrote: On 03/06/2012 10:05 PM, ixid wrote: Ah, thank you, so it's wrapping. That seems like a bad idea, what is the benefit to size being unsigned rather than signed? This case would seem like one where allowing negatives is clearly

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread Timon Gehr
On 03/07/2012 07:05 AM, ixid wrote: Ah, thank you, so it's wrapping. That seems like a bad idea, what is the benefit to size being unsigned rather than signed? This case would seem like one where allowing negatives is clearly better and more intuitive. The problem is not that length is

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread Timon Gehr
On 03/07/2012 11:01 AM, Timon Gehr wrote: On 03/07/2012 07:05 AM, ixid wrote: Ah, thank you, so it's wrapping. That seems like a bad idea, what is the benefit to size being unsigned rather than signed? This case would seem like one where allowing negatives is clearly better and more intuitive.

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread Andrej Mitrovic
On 3/7/12, Timon Gehr timon.g...@gmx.ch wrote: The problem is not that length is unsigned. The issue is the implicit conversion from signed to unsigned. You bet. I've once had this hard to spot bug where I've used a call that was something like max(0, min(10, expression)), and this ended up

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread Jonathan M Davis
On Wednesday, March 07, 2012 11:01:05 Timon Gehr wrote: On 03/07/2012 07:05 AM, ixid wrote: Ah, thank you, so it's wrapping. That seems like a bad idea, what is the benefit to size being unsigned rather than signed? This case would seem like one where allowing negatives is clearly better

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread Sean Cavanaugh
On 3/7/2012 12:57 PM, Jonathan M Davis wrote: On Wednesday, March 07, 2012 11:01:05 Timon Gehr wrote: On 03/07/2012 07:05 AM, ixid wrote: Ah, thank you, so it's wrapping. That seems like a bad idea, what is the I suspect that the reality of the matter is that if we disallowed implicit

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread Jonathan M Davis
On Wednesday, March 07, 2012 13:20:41 Sean Cavanaugh wrote: On 3/7/2012 12:57 PM, Jonathan M Davis wrote: On Wednesday, March 07, 2012 11:01:05 Timon Gehr wrote: On 03/07/2012 07:05 AM, ixid wrote: Ah, thank you, so it's wrapping. That seems like a bad idea, what is the I suspect that

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread Ary Manzana
On 3/7/12 2:28 AM, Ali Çehreli wrote: On 03/06/2012 09:11 PM, ixid wrote: I'm writing my first basic algorithms, this one is merge sort. This version throws an exception when array.length - setSize is negative (which should be fine, the rest of my function would deal with it): template

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread James Miller
On 8 March 2012 15:39, Ary Manzana a...@esperanto.org.ar wrote: On 3/7/12 2:28 AM, Ali Çehreli wrote: On 03/06/2012 09:11 PM, ixid wrote:   I'm writing my first basic algorithms, this one is merge sort. This   version throws an exception when array.length - setSize is negative   (which

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread Jonathan M Davis
On Thursday, March 08, 2012 16:15:08 James Miller wrote: Its the semantics in C/C++ and D explicitly tries to have the same semantics as them. From what I remember its to aid people moving from those language to D. More like it's to avoid code silently breaking when it's ported. In general,

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread Ellery Newcomer
On 03/07/2012 12:23 AM, Ali Çehreli wrote: There are probably hundreds of discussions about that over the years on many different language newsgroups and forums. :) There is no clear winner: Both sides of the arguments seem to have good points. Ali know any good ones off the top of your

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread Ali Çehreli
On 03/07/2012 07:51 PM, Ellery Newcomer wrote: On 03/07/2012 12:23 AM, Ali Çehreli wrote: There are probably hundreds of discussions about that over the years on many different language newsgroups and forums. :) There is no clear winner: Both sides of the arguments seem to have good points.

0 negative loop condition bug or misunderstanding on my part

2012-03-06 Thread ixid
I'm writing my first basic algorithms, this one is merge sort. This version throws an exception when array.length - setSize is negative (which should be fine, the rest of my function would deal with it): template mergeSort(T) { void mergeSort(ref T[] array, const T setSize = 100)

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-06 Thread Ali Çehreli
On 03/06/2012 09:11 PM, ixid wrote: I'm writing my first basic algorithms, this one is merge sort. This version throws an exception when array.length - setSize is negative (which should be fine, the rest of my function would deal with it): template mergeSort(T) { void mergeSort(ref T[]

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-06 Thread H. S. Teoh
On Wed, Mar 07, 2012 at 06:11:18AM +0100, ixid wrote: I'm writing my first basic algorithms, this one is merge sort. This version throws an exception when array.length - setSize is negative (which should be fine, the rest of my function would deal with it): [...] array.length is of type

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-06 Thread ixid
Ah, thank you, so it's wrapping. That seems like a bad idea, what is the benefit to size being unsigned rather than signed? This case would seem like one where allowing negatives is clearly better and more intuitive.

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-06 Thread Ali Çehreli
On 03/06/2012 10:05 PM, ixid wrote: Ah, thank you, so it's wrapping. That seems like a bad idea, what is the benefit to size being unsigned rather than signed? This case would seem like one where allowing negatives is clearly better and more intuitive. There are probably hundreds of

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-06 Thread H. S. Teoh
On 03/06/2012 10:05 PM, ixid wrote: Ah, thank you, so it's wrapping. That seems like a bad idea, what is the benefit to size being unsigned rather than signed? Because it doesn't make sense to have something with a negative size? This case would seem like one where allowing negatives is