Why is size_t unsigned?

Ali Çehreli acehreli at yahoo.com
Sun Jul 21 22:12:51 PDT 2013


On 07/21/2013 09:36 PM, JS wrote:

 > On Monday, 22 July 2013 at 03:58:31 UTC, Ali Çehreli wrote:

 >> > There seems to be no real good reason why size_t is
 >> unsigned...
 >>
 >> How about, every addressable memory locations must be countable?
 >
 > for strings themselves, I would prefer an int to be returned. The size
 > of a string has nothing to do with it's location in memory.

So, you agree with the answer to the question in the subject line but 
you want to change the topic to strings. Fair enough...

 >> D is behaving the same way as C and C++ there.
 >
 > No, surely not... Well, at least, I never had this trouble in C#.

C# is a completely different language from C and C++.

 >> > please don't tell me to use foreach... isn't not a panacea.
 >>
 >> I would still prefer foreach because it is more convenient and safer
 >> because of needing less code.
 >>
 >> Ali
 >
 > foreach doesn't allow you to modify the index to skip over elements.

I did not claim otherwise. I said "more convenient", which is 
indisputable; and I said "safer", which your original code has become an 
example of.

Ali



More information about the Digitalmars-d-learn mailing list