Richard Lynch wrote:
On Mon, June 5, 2006 9:00 pm, tedd wrote:
Does that make more sense?
Maybe to you, but not me.

                   a
                   b
                   c
                   .
                   .
                   .
                   x
                   y
                   z
                  aa
                  ab
                  ac
                   .
                   .
                   .
                  ax
                  ay
                  az
                  ba
                  bb
                  bc
                   .
                   .
                   .
                 aaa
                   .
                   .
                   .
                 zzz
                aaaa
                   .
                   .
                   .
                zzzz
                   .
                   .
                   .
aaaaaaaaaaaaaaaaaaaa
                   .
                   .
                   .
zzzzzzzzzzzzzzzzzzzz

It's just like 1 thru 9 followed by 10, except that it is NOT an
ordered set in terms of < and >

In my last post I showed an "actual sequence" which is debatable. It
could be interpreted that the infinite set starts at "a, aa, aaa,... "
and never reaches "b". Oddly enough, this could be viewed in all sorts
of ways. It's probably best if we don't look at characters as numbers.

EXACTLY!

They aren't numbers.

So doing ++ to one of them, doesn't necessarily end up with an ordered
set.

Rasmus chose to make ++ be useful for generating sensible sequential
file names, not sensible ordered strings.

Well, it does other sequences too and the first priority is always to try to convert to a number. For example, try incrementing the following strings: "1", "1.5", "0xf8", "10e2" These all end up being converted to numbers (integers or floats as appropriate) and hopefully they end up with the value everyone would expect. Since the Web by definition is untyped, all we get passed around between the browser and the server are strings, so we need to make "123" passed as a string behave as the number 123 as much as we can. Otherwise we would spend a lot of time type juggling. Having "123"++ not end up being 124 but instead do something to increment the ascii values behind the string instead would create chaos.

So, given that in any instance where we can convert the string to a number ++ logically increments that number by 1 spot in the numeric sequence. It follows that anywhere we can determine a logical sequence for the string, ++ should increment that sequence. The other option would be that anything that can't be converted to a number would end up being 0, and "whatever"++ would always be 1.

Or we try to do something a bit more creative which always runs the risk of surprising people. In this case "a2"++ becomes "a3" and "c9"++ becomes "d0". If we have a character that doesn't infer any sort of logical sequence, like "&" then the ++ does nothing. So "&"++ stays at "&". However "&3" becomes "&4" and "&b"++ becomes "&c". "99z"++ becomes "100a" and "1z9z9z"++ becomes "2a0a0a" and yes, of course "z"++ becomes "aa" which is what caused this entire thread.

-Rasmus

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to