Re: [PHP] When is z != z ?

2006-06-07 Thread tedd
At 11:45 PM -0400 6/6/06, Robert Cummings wrote: On Tue, 2006-06-06 at 22:53, Rasmus Lerdorf wrote: Richard Lynch wrote: 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

RE: [PHP] When is z != z ?

2006-06-06 Thread Ford, Mike
On 06 June 2006 02:35, tedd wrote: a b c ... x y z aa ab ac ... yx yy yz za zb zc ... zy zx zz aaa aab -- it's not! Yes it is. The ++ operator generates that sequence when applied to a string, and nothing you can say or do will alter that fact. You're trying to treat the 2nd and 3rd

Re: [PHP] When is z != z ?

2006-06-06 Thread Martin Alterisio
2006/6/6, Robert Cummings [EMAIL PROTECTED]: On Tue, 2006-06-06 at 00:01, Martin Alterisio wrote: Because defining ++ and and in such a way as to make them behave like numbers would have made them not work for alphabetizing. A string is a string, and comparison of strings is alphabetic

Re: [PHP] When is z != z ?

2006-06-06 Thread Rasmus Lerdorf
Martin Alterisio wrote: You're right about ++ operator not to be considered a math operator, my mistake. What I should have said is that the usual connotation and expected behaviour of ++ and the comparison operators is to give iteration capabilities to a certain data type, as used in a for

Re: [PHP] When is z != z ?

2006-06-06 Thread Barry
Martin Alterisio schrieb: is it really worthy the functionality supplied with the string ++ operator as it is? I don't see its usefullness yet. guess you want to order something by name not by number which might be false in some cases (1,10,2,20,21 ... and so on). There it might be useful.

Re: [PHP] When is z != z ?

2006-06-06 Thread Martin Alterisio
2006/6/6, Barry [EMAIL PROTECTED]: Martin Alterisio schrieb: is it really worthy the functionality supplied with the string ++ operator as it is? I don't see its usefullness yet. guess you want to order something by name not by number which might be false in some cases (1,10,2,20,21 ... and

Re: [PHP] When is z != z ?

2006-06-06 Thread Martin Alterisio
2006/6/6, Rasmus Lerdorf [EMAIL PROTECTED]: Martin Alterisio wrote: You're right about ++ operator not to be considered a math operator, my mistake. What I should have said is that the usual connotation and expected behaviour of ++ and the comparison operators is to give iteration

Re: [PHP] When is z != z ?

2006-06-06 Thread Robert Cummings
On Tue, 2006-06-06 at 09:46, Martin Alterisio wrote: 2006/6/6, Robert Cummings [EMAIL PROTECTED]: In C++ they do leave it to the coder, and well, we all know what a mess it can be deciphering overloaded operators in C++ (or maybe we ALL don't). At any rate, the PHP overlords made a choice,

Re: [PHP] When is z != z ?

2006-06-06 Thread tedd
Rasmus: At 6:54 PM -0700 6/5/06, Rasmus Lerdorf wrote: tedd wrote: For example, the Unicode issue was raised during this discussion -- if php doesn't consider the numeric relationship of characters, then I see a big problem waiting in the wings. Because if we're having these types of

Re: [PHP] When is z != z ?

2006-06-06 Thread Martin Alterisio
2006/6/6, Robert Cummings [EMAIL PROTECTED]: On Tue, 2006-06-06 at 09:46, Martin Alterisio wrote: 2006/6/6, Robert Cummings [EMAIL PROTECTED]: In C++ they do leave it to the coder, and well, we all know what a mess it can be deciphering overloaded operators in C++ (or maybe we ALL

Re: [PHP] When is z != z ?

2006-06-06 Thread Adam Zey
tedd wrote: for I can't get it to stop when it passes z -- which I think it should. But, people have posted code solutions for you to do exactly what you want. So have I. Here it is again: foreach (range('a', 'z') as $char) { echo $char; } I don't mean to sound harsh, but why are you

Re: [PHP] When is z != z ?

2006-06-06 Thread Robert Cummings
On Tue, 2006-06-06 at 13:05, tedd wrote: I don't have these issues because I'm not Lithuanian. If a Lithuanian php programmer wants y to fall between i and k in a loop, then good luck -- for I can't get it to stop when it passes z -- which I think it should. This isbecause you're using the

Re: [PHP] When is z != z ?

2006-06-06 Thread Robert Cummings
On Tue, 2006-06-06 at 13:11, Martin Alterisio wrote: 2006/6/6, Robert Cummings [EMAIL PROTECTED]: On Tue, 2006-06-06 at 09:46, Martin Alterisio wrote: 2006/6/6, Robert Cummings [EMAIL PROTECTED]: In C++ they do leave it to the coder, and well, we all know what a mess it can be

Re: [PHP] When is z != z ?

2006-06-06 Thread Paul Novitski
At 10:38 AM 6/4/2006, tedd wrote: for ($i=a; $iz; $i++) { echo($i); } -- it stops at y But, if you use -- for ($i=a; $i=z; $i++) { echo($i); } -- it prints considerably more characters after z than what one would normally expect -- why is that? Tedd, The discussion of PHP

Re: [PHP] When is z != z ?

2006-06-06 Thread tedd
At 1:14 PM -0400 6/6/06, Adam Zey wrote: tedd wrote: for I can't get it to stop when it passes z -- which I think it should. But, people have posted code solutions for you to do exactly what you want. So have I. Here it is again: foreach (range('a', 'z') as $char) { echo $char; } I don't

Re: [PHP] When is z != z ?

2006-06-06 Thread Martin Alterisio
2006/6/6, Robert Cummings [EMAIL PROTECTED]: On Tue, 2006-06-06 at 13:11, Martin Alterisio wrote: 2006/6/6, Robert Cummings [EMAIL PROTECTED]: On Tue, 2006-06-06 at 09:46, Martin Alterisio wrote: 2006/6/6, Robert Cummings [EMAIL PROTECTED]: In C++ they do leave it to the coder,

Re: [PHP] When is z != z ?

2006-06-06 Thread tedd
Tedd, The discussion of PHP strings has been interesting; thanks for sparking that. Of course, your subject line to the contrary, it's not that z != z, it's that storing an alphabetic character assumed to be a single byte in a variable and then incrementing it can result in a two-byte result.

Re: [PHP] When is z != z ?

2006-06-06 Thread Martin Alterisio
2006/6/6, tedd [EMAIL PROTECTED]: If php is supposed to be open source, doesn't that mean that people can voice their opinion on what they observe and expect? I second that. I believe being open-source doesn't mean Yay, it's free! but Cool, someone is listening to us!

Re: [PHP] When is z != z ?

2006-06-06 Thread Robert Cummings
On Tue, 2006-06-06 at 14:06, Martin Alterisio wrote: 2006/6/6, Robert Cummings [EMAIL PROTECTED]: You must have missed this post: http://marc.theaimsgroup.com/?l=php-generalm=114945456908350w=2 Yes, I haven't read that post. That algorithm has an error, an overflow on a

Re: [PHP] When is z != z ?

2006-06-06 Thread John Nichel
tedd wrote: snip And I thank you for your reply -- you've been much kinder than most (on and off-list). :-) True the subject line was a bit misleading, but that was intentional. Bait causes more fish to rise. I've received the answer several times over since I posted the problem, but I

Re: [PHP] When is z != z ?

2006-06-06 Thread Martin Alterisio
2006/6/6, Robert Cummings [EMAIL PROTECTED]: On Tue, 2006-06-06 at 14:06, Martin Alterisio wrote: 2006/6/6, Robert Cummings [EMAIL PROTECTED]: You must have missed this post: http://marc.theaimsgroup.com/?l=php-generalm=114945456908350w=2 Yes, I haven't read that post.

Re: [PHP] When is z != z ?

2006-06-06 Thread tedd
At 2:20 PM -0400 6/6/06, John Nichel wrote: tedd wrote: snip And I thank you for your reply -- you've been much kinder than most (on and off-list). :-) True the subject line was a bit misleading, but that was intentional. Bait causes more fish to rise. I've received the answer several times

Re: [PHP] When is z != z ?

2006-06-06 Thread Robert Cummings
On Tue, 2006-06-06 at 14:31, Martin Alterisio wrote: 2006/6/6, Robert Cummings [EMAIL PROTECTED]: On Tue, 2006-06-06 at 14:06, Martin Alterisio wrote: 2006/6/6, Robert Cummings [EMAIL PROTECTED]: You must have missed this post:

Re: [PHP] When is z != z ?

2006-06-06 Thread Martin Alterisio
2006/6/6, Robert Cummings [EMAIL PROTECTED]: On Tue, 2006-06-06 at 14:31, Martin Alterisio wrote: 2006/6/6, Robert Cummings [EMAIL PROTECTED]: On Tue, 2006-06-06 at 14:06, Martin Alterisio wrote: 2006/6/6, Robert Cummings [EMAIL PROTECTED]: You must have missed this post:

Re: [PHP] When is z != z ?

2006-06-06 Thread Robert Cummings
On Tue, 2006-06-06 at 15:11, Martin Alterisio wrote: 2006/6/6, Robert Cummings [EMAIL PROTECTED]: You lost me there. Can you explain it a little bit further? You said: Still, an overload is an known issue and that can be caught easily. It follows that you need

Re: [PHP] When is z != z ?

2006-06-06 Thread Richard Lynch
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

Re: [PHP] When is z != z ?

2006-06-06 Thread Rasmus Lerdorf
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

Re: [PHP] When is z != z ?

2006-06-06 Thread Robert Cummings
On Tue, 2006-06-06 at 22:53, Rasmus Lerdorf wrote: Richard Lynch wrote: 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

Re: [PHP] When is z != z ?

2006-06-05 Thread tg-php
I know this discussion doesn't need to continue any further..hah.. but I think the biggest confusion people are having is that they're looking at two things and assuming that PHP operates the same on both and these two things serve different purposes. 1. Incrementing strings: Best example

Re: [PHP] When is z != z ?

2006-06-05 Thread tedd
-TG: Thanks for your explanation and time. Normally, I don't alpha++ anything -- not to criticize others, but to me it doesn't make much sense to add a number to a character. But considering the php language is so string aware, as compared to other languages, I just tried it on a lark just

Re: [PHP] When is z != z ?

2006-06-05 Thread Adam Zey
tedd wrote: -TG: Thanks for your explanation and time. Normally, I don't alpha++ anything -- not to criticize others, but to me it doesn't make much sense to add a number to a character. But considering the php language is so string aware, as compared to other languages, I just tried it on

Re: [PHP] When is z != z ?

2006-06-05 Thread Robert Cummings
On Mon, 2006-06-05 at 12:49, tedd wrote: -TG: Thanks for your explanation and time. Normally, I don't alpha++ anything -- not to criticize others, but to me it doesn't make much sense to add a number to a character. But considering the php language is so string aware, as compared to

Re: [PHP] When is z != z ?

2006-06-05 Thread tg-php
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

Re: [PHP] When is z != z ?

2006-06-05 Thread Martin Alterisio
2006/6/5, [EMAIL PROTECTED] [EMAIL PROTECTED]: 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

Re: [PHP] When is z != z ?

2006-06-05 Thread Larry Garfield
On Monday 05 June 2006 14:56, Martin Alterisio wrote: 2006/6/5, [EMAIL PROTECTED] [EMAIL PROTECTED]: 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

Re: [PHP] When is z != z ?

2006-06-05 Thread tedd
At 1:10 PM -0400 6/5/06, Robert Cummings wrote: NO! More must be said!! a = z b = z c = z -snip- yx = z yy = z yz = z zaz Sooo, the comparisons stop before we get to aaa and so aaa is never reached. za is the last comparison to occur at which point the

Re: [PHP] When is z != z ?

2006-06-05 Thread Rasmus Lerdorf
tedd wrote: For example, the Unicode issue was raised during this discussion -- if php doesn't consider the numeric relationship of characters, then I see a big problem waiting in the wings. Because if we're having these types of discussions with just considering 00-7F characters, then I can

Re: [PHP] When is z != z ?

2006-06-05 Thread Robert Cummings
On Mon, 2006-06-05 at 21:35, tedd wrote: At 1:10 PM -0400 6/5/06, Robert Cummings wrote: NO! More must be said!! a = z b = z c = z -snip- yx = z yy = z yz = z zaz Sooo, the comparisons stop before we get to aaa and so aaa is never reached.

Re: [PHP] When is z != z ?

2006-06-05 Thread tedd
At 8:18 PM -0500 6/5/06, Larry Garfield wrote: 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

Re: [PHP] When is z != z ?

2006-06-05 Thread Martin Alterisio
2006/6/5, Larry Garfield [EMAIL PROTECTED]: On Monday 05 June 2006 14:56, Martin Alterisio wrote: 2006/6/5, [EMAIL PROTECTED] [EMAIL PROTECTED]: 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

Re: [PHP] When is z != z ?

2006-06-05 Thread Robert Cummings
On Mon, 2006-06-05 at 22:00, tedd wrote: At 8:18 PM -0500 6/5/06, Larry Garfield wrote: 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

Re: [PHP] When is z != z ?

2006-06-05 Thread Larry Garfield
On Monday 05 June 2006 21:12, Martin Alterisio wrote: 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

Re: [PHP] When is z != z ?

2006-06-05 Thread Martin Alterisio
2006/6/6, Larry Garfield [EMAIL PROTECTED]: On Monday 05 June 2006 21:12, Martin Alterisio wrote: 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

Re: [PHP] When is z != z ?

2006-06-05 Thread Robert Cummings
On Tue, 2006-06-06 at 00:01, Martin Alterisio wrote: Because defining ++ and and in such a way as to make them behave like numbers would have made them not work for alphabetizing. A string is a string, and comparison of strings is alphabetic (for some definition of alphabet). It's more

Re: [PHP] When is z != z ?

2006-06-04 Thread Rasmus Lerdorf
tedd wrote: Hi gang: Here's your opportunity to pound me again for not knowing the basics of php. I vaguely remember something like this being discussed a while back, but can't find the reference. In any event, if one uses -- for ($i=a; $iz; $i++) { echo($i); } -- it stops at y

Re: [PHP] When is z != z ?

2006-06-04 Thread Martin Alterisio
2006/6/4, Rasmus Lerdorf [EMAIL PROTECTED]: tedd wrote: Hi gang: Here's your opportunity to pound me again for not knowing the basics of php. I vaguely remember something like this being discussed a while back, but can't find the reference. In any event, if one uses -- for ($i=a; $iz;

Re: [PHP] When is z != z ?

2006-06-04 Thread Rasmus Lerdorf
Martin Alterisio wrote: 2006/6/4, Rasmus Lerdorf [EMAIL PROTECTED]: tedd wrote: Hi gang: Here's your opportunity to pound me again for not knowing the basics of php. I vaguely remember something like this being discussed a while back, but can't find the reference. In any event, if one

Re: [PHP] When is z != z ?

2006-06-04 Thread Martin Alterisio
2006/6/4, Rasmus Lerdorf [EMAIL PROTECTED]: Martin Alterisio wrote: 2006/6/4, Rasmus Lerdorf [EMAIL PROTECTED]: tedd wrote: Hi gang: Here's your opportunity to pound me again for not knowing the basics of php. I vaguely remember something like this being discussed a while back,

Re: [PHP] When is z != z ?

2006-06-04 Thread tedd
At 11:08 AM -0700 6/4/06, Rasmus Lerdorf wrote: tedd wrote: But, if you use -- for ($i=a; $i=z; $i++) { echo($i); } -- it prints considerably more characters after z than what one would normally expect -- why is that? Just stopping at z would seem to make more sense, wouldn't it? After

Re: [PHP] When is z != z ?

2006-06-04 Thread Rasmus Lerdorf
tedd wrote: But, what brothers me about the routine, is that is DOES print z where it is supposed to. In other words, the characters a-z are output before continuing with aa and so on. The operation doesn't end with z. Your condition for the loop to continue is $i=z. When $i = y it will

Re: [PHP] When is z != z ?

2006-06-04 Thread Rasmus Lerdorf
Martin Alterisio wrote: Still: anything ++anything should be true, or at least that's what they taught me on abstract data types design, and I think they're right (at least this time) In loosely typed languages that is not always true. Operators have to guess at the type and try to do what

Re: [PHP] When is z != z ?

2006-06-04 Thread Martin Alterisio
2006/6/4, Rasmus Lerdorf [EMAIL PROTECTED]: Martin Alterisio wrote: Still: anything ++anything should be true, or at least that's what they taught me on abstract data types design, and I think they're right (at least this time) In loosely typed languages that is not always true.

Re: [PHP] When is z != z ?

2006-06-04 Thread Rasmus Lerdorf
Martin Alterisio wrote: I still don't see why this functionality should be a native operator of the language. It doesn't seem natural that ++ operator understands that the string could be an enumeration of some kind. I believe that such things should be left to the coder who knows what the

Re: [PHP] When is z != z ?

2006-06-04 Thread tedd
At 12:27 PM -0700 6/4/06, Rasmus Lerdorf wrote: tedd wrote: But, what brothers me about the routine, is that is DOES print z where it is supposed to. In other words, the characters a-z are output before continuing with aa and so on. The operation doesn't end with z. Your condition for the loop

Re: [PHP] When is z != z ?

2006-06-04 Thread tedd
At 12:40 PM -0700 6/4/06, Rasmus Lerdorf wrote: For example, this also works: $filename = file1; $filename++; echo $filename; You would get file2 from this. Think about the amount of code you would need to write in C to make that work? I would rather not. :-) tedd --

Re: [PHP] When is z != z ?

2006-06-04 Thread Rasmus Lerdorf
tedd wrote: At 12:27 PM -0700 6/4/06, Rasmus Lerdorf wrote: tedd wrote: But, what brothers me about the routine, is that is DOES print z where it is supposed to. In other words, the characters a-z are output before continuing with aa and so on. The operation doesn't end with z. Your

Re: [PHP] When is z != z ?

2006-06-04 Thread tedd
At 1:09 PM -0700 6/4/06, Rasmus Lerdorf wrote: I agree with [1] and [2], but [3] is where we part company. You see, if you are right, then aaa would also be less than z, but that doesn't appear so. Of course it is. php -r 'echo aaa z;' 1 You missed the point, why does -- for ($i=a; $i=z;

Re: [PHP] When is z != z ?

2006-06-04 Thread Robert Cummings
On Sun, 2006-06-04 at 16:45, tedd wrote: At 1:09 PM -0700 6/4/06, Rasmus Lerdorf wrote: I agree with [1] and [2], but [3] is where we part company. You see, if you are right, then aaa would also be less than z, but that doesn't appear so. Of course it is. php -r 'echo aaa z;' 1

Re: [PHP] When is z != z ?

2006-06-04 Thread Robert Cummings
On Sun, 2006-06-04 at 16:53, Robert Cummings wrote: -- not continue past aaa? Clearly, if aaa is less than z then why does the loop stop at yz? Because right after 'yz' there is 'zz' and 'z' is neither less than nor equal to 'zz'. Err, that should say 'zz' is neither less than nor

Re: [PHP] When is z != z ?

2006-06-04 Thread Robert Cummings
On Sun, 2006-06-04 at 15:10, Martin Alterisio wrote: Still: anything ++anything should be true, or at least that's what they taught me on abstract data types design, and I think they're right (at least this time) There's always limitations :) int main( char *argv[], int argc ) { int i

Re: [PHP] When is z != z ?

2006-06-04 Thread Larry Garfield
On Sunday 04 June 2006 15:04, tedd wrote: Yes, it is my contention that strings are numerical -- you don't store A in memory, you store 0100 001, or ASCII DEC 65. In a low-level language like C, that matters. One doesn't have strings, one has numbers that happen to map to a symbol. In PHP

Re: [PHP] When is z != z ?

2006-06-04 Thread Ryan A
clip There will always be edge cases. Being able to increment strings is pretty handy when you need to create sequences for unique file and directory names. For example, this also works: $filename = file1; $filename++; echo $filename; You would get file2 from this. Think about

Re: [PHP] When is z != z ?

2006-06-04 Thread tedd
At 4:53 PM -0400 6/4/06, Robert Cummings wrote: On Sun, 2006-06-04 at 16:45, tedd wrote: -- not continue past aaa? Clearly, if aaa is less than z then why does the loop stop at yz? Because right after 'yz' there is 'zz' and 'z' is neither less than nor equal to 'zz'. and At 4:37 PM -0500

Re: [PHP] When is z != z ?

2006-06-04 Thread Rasmus Lerdorf
tedd wrote: At 1:09 PM -0700 6/4/06, Rasmus Lerdorf wrote: I agree with [1] and [2], but [3] is where we part company. You see, if you are right, then aaa would also be less than z, but that doesn't appear so. Of course it is. php -r 'echo aaa z;' 1 You missed the point, why does -- for

Re: [PHP] When is z != z ?

2006-06-04 Thread Rasmus Lerdorf
Larry Garfield wrote: On Sunday 04 June 2006 15:04, tedd wrote: Yes, it is my contention that strings are numerical -- you don't store A in memory, you store 0100 001, or ASCII DEC 65. In a low-level language like C, that matters. One doesn't have strings, one has numbers that happen to