2006/6/5, Larry Garfield <larry@xxxxxxxxxxxxxxxx>:
On Monday 05 June 2006 14:56, Martin Alterisio wrote: > 2006/6/5, tg-php@xxxxxxxxxxxxxxxxxxxxxx <tg-php@xxxxxxxxxxxxxxxxxxxxxx>: > > This is just one of those cases where the designers had to make a > > judgement call on how things were going to operate. It makes sense if > > you look at the two things separately (incrementing vs string 'greatness' > > evaluation) and makes sense that how they chose to implement the > > functions are two valid choices among many ways that it could have been > > handled. > > How does it make sense? I don't understand your argument, can you explain > it a little bit more? See Robert Cummings' post. < and > are being interpreted in this case for alphabetical order. Read "<" as "alphabetically before", and <= as "alphabetically before or string-equal to". Is a alphabetically before or string-equal to z? TRUE. Is b alphabetically before or string-equal to z? TRUE. ... Is z alphabetically before or string-equal to z? TRUE. (string-equal) Is aa alphabetically before or string-equal to z? TRUE. (a < z alphabetically, the second character is never checked). Is ab alphabetically before or string-equal to z? TRUE. ... Is yz alphabetically before or string-equal to z? TRUE. Is za alphabetically before or string-equal to z? FALSE. (a alphabetically after NULL character. Bob is alphabetically before Bobby for the same reason.) See how the comparison works? It's a purely alphabetic comparison. As for the increment, it actually would never have occurred to me to ++ a string before this thread, honestly. :-) However, what it appears to be doing (and I'm sure Rasmus will correct me if I'm wrong) is using a "string base" instead of a numeric base. Thus a++ = b, b++=c, etc. z++ "rolls over" to the next "digit" (which because it's a string goes to the right rather than the left), and resets. So just as 9++ rolls over to 10, z rolls over to aa. Does that make more sense?
You misunderstood me, I completely understand how the operators function, but you're saying it makes sense the way their functionality is assigned, what I want to know is the reasons you have that support those affirmations. I completely understand that string comparison is done alphabetically, but how does having the functionality for the ++ operator create a sequence that are inconsistent with the comparison operator, makes sense?