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 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

Funky stuff.

  1z9z9z++ becomes 2a0a0a and yes, of course z++

Good thing Tedd didn't come across the above one by accident *lol*.

Cheers,
Rob.

Well... now that you mentioned it :-)

Good discussion all.

Thanks for everyone's input, learned a lot -- and hopefully didn't annoy too 
many.

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



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 elements of the for () statement as an 
integrated unit, but they're not - the 2nd element generates the elements of 
the sequence in whatever order it generates in, and the 3rd element simply 
applies a test to the generated values and causes the sequence to stop the 
first time the test fails -- it's not in any way a limiter for what values will 
be generated.

Using simple integers, I could code something like this, which would exhibit 
similar properties:

   for ($i=0; $i=($i+7)%100; $i99)

The expression $i=($i+7)%100 is a generator for all integers in the set 
[0,100], but in a non-linear order; the test $i99 will cause the loop to stop 
part way through the generated sequence, before some of the values which would 
satisfy the test have been produced.

 You can't say that a and aaa are members of a set
 identified as  z and then step through all the members of
 that population (an infinite group) and not include aaa --
 UNLESS -- you arbitrarily determine an end point for a much
 smaller sub-set.

See argument above: you're not stepping through all members of the set  z -- 
or even, as in the original loop, = z -- you're stepping through all members 
of the set of strings containing any number of the characters [a-z] in any 
combination, in the order defined by the ++ operator, and terminating on the 
first generated element which is *not* = z.  There's nothing in there that 
says you have to generate *all* strings = z before terminating -- just that 
you stop on generating one that isn't.

 Now, unless, there is something that I don't see, which
 certainly could be the case, then php designers could have
 just as easily ended the loop at z and dispensed with this
 quirk all together.

Well, if the quirk were eliminated by making z++ be the next character in the 
ASCII sequence, the loop would still not end at z -- it would end on 
encountering { (if I remember my ASCII correctly).

 Besides, what's the point of having 676 character between a
 and z? Is there one?

No. And there aren't. There are 676 *strings, of length 1 and 2, as generated 
by the ++ operator.

You have to remember that there is no such type as 'character' in PHP -- just 
strings of length 1.  And strings don't (necessarily) behave like characters.

 But this is the way it is and I except that -- but as Dirty
 Harry once said A man's got to know his limitations -- this
 not only applies to men and programmers, but also for
 languages as well.
 
 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 only guess at what's going to happen when we start
 considering 00-FF code-points.

Well, the PHP manual says: Note that character variables can be incremented 
but not decremented and even so only plain ASCII characters (a-z and A-Z) are 
supported.  If that continues to be the case, then the Unicode argument may be 
moot.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



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 (for some definition
of
  alphabet).  It's more useful to deal with strings as strings than to
make
  them quack like numbers.
 

 Then, if it's not a math operation, why use a math operator for such
 functionality? In which way is the ++ operator that generates a string

I don't ever remember seeing ++ in math class. I do remember seeing it
in lots of computer classes and to that end it was just an operator
with whatever semantic meaning was applied to it for a given language. I
guess it's usually to increment an integer, but that's just in
general. I mean if we want to get into math operators being used for
string purposes, then we should look at how many languages use the +
operator to concatenate two strings -- by your accounts they should
treat their operands as integers and do a rote addition.

 sequence, useful enough to justify the formal inconsistency between the
math
 operators? I still don't see the advantages of having the ++ recognize
the
 string as a sequence, and generate the next item in the sequence. I
believe
 those decisions should be left to the coder, because he knows what the
 string really represents and which kind of sequence is being used.

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, and IMHO the best
choice. For such a fringe issue I don't see what the argument is all
about. If you want the functionality you get in C by incrementing a
char, then use the chr() function on an integer.



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 statement. For that to
happen certain constrains must be true for these operators, one of them
being: any  ++any, which is not true for the way these operators behave in
php.

I'm not saying It's wrong let's change it right away!, I completely agree
that these rules can be bent on a not strongly typed language. The point I'm
trying to make, the thing I want to understant without a trace of doubt, is:
is it really worthy the functionality supplied with the string ++ operator
as it is? I don't see its usefullness yet.


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 statement. For 
that to

happen certain constrains must be true for these operators, one of them
being: any  ++any, which is not true for the way these operators behave in
php.

I'm not saying It's wrong let's change it right away!, I completely agree
that these rules can be bent on a not strongly typed language. The point 
I'm
trying to make, the thing I want to understant without a trace of doubt, 
is:

is it really worthy the functionality supplied with the string ++ operator
as it is? I don't see its usefullness yet.


It has been in PHP from the very beginning.  So 10+ years.  In that time 
it has been sparingly used, granted, but at the same time it really 
hasn't gotten in the way and removing it would break a number of legacy 
applications.


There were a lot more operators that worked on strings in the early 
days.  '*' would do a cross-product, for example, treating the two 
string operands as vectors and returning a vector orthogonal to both of 
these.  But I got tired of trying to explain to people what a cross 
product was and how strings mapped to vectors in Euclidean space and 
removed that.  You could also at one point do abc-b to get ac.


-Rasmus

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



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.

Well i don think it is wrong behavior in that way.

because having looping from a till z you wil get aa after z  so that 
means aa is higher as z internally.


but looping till aa dont brings out a-z like you get a-y when you loop 
till z (remember: for $i = a; $i = z; $i++ gives the chars a-yz z right 
followed by aa)


Well if you implement something like that into a programming language it 
should at least have some kind of logic behavior. Don't you think?


--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

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



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 so on).

There it might be useful.

Well i don think it is wrong behavior in that way.

because having looping from a till z you wil get aa after z  so that
means aa is higher as z internally.

but looping till aa dont brings out a-z like you get a-y when you loop
till z (remember: for $i = a; $i = z; $i++ gives the chars a-yz z right
followed by aa)

Well if you implement something like that into a programming language it
should at least have some kind of logic behavior. Don't you think?



That's okay, but not where my doubts are. I have not objections to the
comparison made alphabetically. What I doubt is the usefullness of
generating sequences with ++.


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
 capabilities to a certain data type, as used in a for statement. For
 that to
 happen certain constrains must be true for these operators, one of them
 being: any  ++any, which is not true for the way these operators behave
in
 php.

 I'm not saying It's wrong let's change it right away!, I completely
agree
 that these rules can be bent on a not strongly typed language. The point
 I'm
 trying to make, the thing I want to understant without a trace of doubt,
 is:
 is it really worthy the functionality supplied with the string ++
operator
 as it is? I don't see its usefullness yet.

It has been in PHP from the very beginning.  So 10+ years.  In that time
it has been sparingly used, granted, but at the same time it really
hasn't gotten in the way and removing it would break a number of legacy
applications.



Well, that's enough reason to me, although a pain in the ass, backward
compatibility is an important issue. There will be plenty of opportunities
in future versions to revise this, for now my mind is at ease.

There were a lot more operators that worked on strings in the early

days.  '*' would do a cross-product, for example, treating the two
string operands as vectors and returning a vector orthogonal to both of
these.  But I got tired of trying to explain to people what a cross
product was and how strings mapped to vectors in Euclidean space and
removed that.  You could also at one point do abc-b to get ac.

-Rasmus



That's quite an anecdote, why isn't it somewhere in the php website or
manual? It's nice to know the humans behind the soft ^_^

That kind of operation might have been useful with arrays, as some other
operations to work with them as if they were sets (inclusion, union,
difference, etc). Yes, we have functions for that but apply a few of them
inside an if statement and I start to have LISP nightmares with all those
parenthesis.


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, and IMHO the best
  choice. For such a fringe issue I don't see what the argument is all
  about. If you want the functionality you get in C by incrementing a
  char, then use the chr() function on an integer.
 
 
 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 statement. For that to
 happen certain constrains must be true for these operators, one of them
 being: any  ++any, which is not true for the way these operators behave in
 php.

You must have missed this post:

http://marc.theaimsgroup.com/?l=php-generalm=114945456908350w=2

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



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 
discussions with just considering 00-7F characters, then I can only guess at 
what's going to happen when we start considering 00-FF code-points.

Now, was that enough said?  :-)

I don't think you really understand this.   and  are collation operators 
when they operate on strings.  They have absolutely nothing to do with the 
numeric values of the characters.

What's to understand?  It's the pecking order of strings  -- it's the system of 
how one sorts strings. It's the way I tried to order my books in college. We've 
been doing it all our life and now you think I don't understand how to sort 
stuff? It's not the white and colored clothes thing my wife keeps talking 
about, is it?

Look, I understand collation. I also understand that collation is different for 
different languages and for different needs. In some cases, greatly different.

The point of this discussion was how php collates/sorts or otherwise orders 
characters/strings when given the operation to increment from a to z.

As this thread has demonstrated, there's a wide range of expectations as to how 
that should happen.

The reference you provided touches upon some of the problems that collation 
faces when trying to develop collation systems for different needs. This 
discussion was no different.

It just so happens that in English iso-8859-1 there is a 1:1 relationship 
between the numeric values and the collation order, but you can think of that 
as dumb luck.

No,  English iso-8859-1 was designed to conform to the ASCII standard-- the 
same as Unicode and other standards that followed. It's not dumb luck to make 
standards backward compatible, it's by good design.

Considering that you're dealing with English iso-8895 and ASCII (developed by 
American Standard Code), then I think the connection between numeric values 
and collation went hand-in-hand by design. It was not by accident.

It's just too bad that the powers-the-be at the time didn't realize that 
7-bit wouldn't cover everything to come in the near future.

To better understand this, I suggest you start reading here:

  http://icu.sourceforge.net/userguide/Collate_Intro.html

Note one of the points on that page.  That in Lithuanian 'y' falls between 'i' 
and 'k'.  So even without going into Unicode and just using low-ascii, you 
have these issues.

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.

But, as I am aware, there is no low-ASCII, there is no high-ASCII, there is 
simply ASCII. While it is common to use the term of extended-ASCII, it's a 
misnomer because American Standards Association had nothing to do with 
establishing/defining any character above DEC 126.

The above example you referenced is simply one of many and demonstrates that 
the collation problem is very complex. You should look into how Unicode 
performs canonical ordering in combining characters such as using an accent, 
umlaut, or cedilla as well as how that combination affects collation in 
different languages as stated in your reference. You will see that canonical 
ordering  algorithm is numeric.

Yes, I'm very aware of Unicode. I'm aware enough to know that they have 
assigned numerical equivalents to every glyph known to man including those 
combining glyphs such as those mentioned above to produce combination 
characters. When I say every glyph known to man, that includes much more than 
language specific glyphs.

I'm also aware of IDNS and how they implement Unicode, which is not inclusive. 
Take for example case mapping which IDNS simply translates all of what they 
perceive to be uppercase to lowercase. Some characters are combination 
characters when lowercase and a single character when uppercase, thus there is 
no lowercase representation for the uppercase character. Oops, I just lost the 
16th century (Roller Ball).

Now, I can appreciate the problems facing php considering that it has to deal 
with not only Unicode, but with also with the IDNS when addressing Unicode and 
the Internet. But that problem is not going to be solved by ignoring that 
Unicode code-points have numeric (and other) values. I would think that serious 
collation systems use numeric values in some fashion in their algorithms -- 
don't they? If not, please explain how they detect differences between 
characters and group them into collation tables.

Now, until we get to PHP 6, we don't have decent Unicode support and we don't 
have LOCALE-aware operators.  You will have to manually use strcoll() to get 
them, but that is going to change and you will have the 

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
  don't). At any rate, the PHP overlords made a choice, and IMHO the
best
  choice. For such a fringe issue I don't see what the argument is all
  about. If you want the functionality you get in C by incrementing a
  char, then use the chr() function on an integer.
 
 
 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 statement. For
that to
 happen certain constrains must be true for these operators, one of them
 being: any  ++any, which is not true for the way these operators behave
in
 php.

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
signed char, and that's implementation issue not a design issue.

PS: It's a little bit rude to say you *must* have missed but I understand
that it wasn't your intention.


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 still complaining about it? 
You've been shown to do exactly what you want, why is it still a problem?


Heck, if you still really want to do  and  with strings, you can 
easily write your own functions to compare two strings using your own 
requirements.


Regards, Adam Zey.

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



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 wrong tool for the job. Don't blame the
tool, blame the user of the tool. if you want to loop from 'a' to 'z'
then use chr() and ord().

?php

for( $i = ord( 'a' ); $i = ord( 'z' ); $i++ )
{
echo Nuff said!\n;
}

?

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



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 deciphering overloaded operators in C++ (or maybe we ALL
don't). At any rate, the PHP overlords made a choice, and IMHO the
  best
choice. For such a fringe issue I don't see what the argument is all
about. If you want the functionality you get in C by incrementing a
char, then use the chr() function on an integer.
   
   
   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 statement. For
  that to
   happen certain constrains must be true for these operators, one of them
   being: any  ++any, which is not true for the way these operators behave
  in
   php.
 
  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
 signed char, and that's implementation issue not a design issue.

Actually it's a design issue. C uses a numeric datatype that is bound by
a specific number of bits. It could just have well have been designed
with a numeric datatype that had arbitrary length. The design decision
was made to keep it close to the machine. However, the point I was
making is that dealing with fringe cases is a necessity when you want to
ensure your code is robust.

 PS: It's a little bit rude to say you *must* have missed but I understand
 that it wasn't your intention.

Sorry, didn't mean to be rude :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



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 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.  I find it plausible that the statement $a = a produces a 
two-byte result in the first place, we just don't notice it because 
the second byte is turned sideways and is very, very skinny.


I assume you know (but I'll state it anyway for the record) that to 
avoid the problems you've encountered by trying to treat apparently 
multi-byte PHP string variables like one-byte numerics, you can 
simply use numerics themselves:


for ($i = ord(a); $i = ord(z); $i++)
{
echo chr($i);
}

ord() and chr() being the PHP functions to yield the numeric value of 
a character and the ASCII character of a numeric value:

http://php.net/ord  http://php.net/chr

To save that hard-working server a few machine cycles, one would 
presumably store ord(z) in a variable before the loop began and 
test for that each iteration.


Warm regards,
Paul 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.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 mean to sound harsh, but why are you still complaining about it? 
You've been shown to do exactly what you want, why is it still a problem?

Heck, if you still really want to do  and  with strings, you can easily 
write your own functions to compare two strings using your own requirements.

Regards, Adam Zey.

Adam:

I don't mean to sound harsh either, but you're missing the topic here. I have 
already said that I found a solution (I said that in day of my first post) -- 
I'm not here asking for another one.

If php is supposed to be open source, doesn't that mean that people can voice 
their opinion on what they observe and expect?

Somehow I thought that a loop going from a to z would produce 26 elements 
and was surprised to find it produced 676. Now, you want to beat me up because 
I'm discussing it?

How about the next time you find something unexpected and want to discus it -- 
remind me and I accuse you of complaining.

No offense meant.

tedd

-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



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, 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, and IMHO the
  best
choice. For such a fringe issue I don't see what the argument is
all
about. If you want the functionality you get in C by incrementing
a
char, then use the chr() function on an integer.
   
   
   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 statement. For
  that to
   happen certain constrains must be true for these operators, one of
them
   being: any  ++any, which is not true for the way these operators
behave
  in
   php.
 
  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
 signed char, and that's implementation issue not a design issue.

Actually it's a design issue. C uses a numeric datatype that is bound by
a specific number of bits. It could just have well have been designed
with a numeric datatype that had arbitrary length. The design decision
was made to keep it close to the machine. However, the point I was
making is that dealing with fringe cases is a necessity when you want to
ensure your code is robust.



I haven't thought this carefully, you're right to point that is a design
issue since compilers and interpreters have to take into account the actual
data representation in the design stage. Still, an overload is an known
issue and that can be caught easily. If you assume that the ++ and
comparison operator can be used with any type of object in a for loop, and
they don't follow the expected contrains an iterator shoud have then the
problem will be less apparent, as the issue is not considered a misuse but a
normal function of the data type.


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.  I find it plausible 
that the statement $a = a produces a two-byte result in the first place, we 
just don't notice it because the second byte is turned sideways and is very, 
very skinny.

I assume you know (but I'll state it anyway for the record) that to avoid the 
problems you've encountered by trying to treat apparently multi-byte PHP 
string variables like one-byte numerics, you can simply use numerics 
themselves:

for ($i = ord(a); $i = ord(z); $i++)
{
echo chr($i);
}

ord() and chr() being the PHP functions to yield the numeric value of a 
character and the ASCII character of a numeric value:
http://php.net/ord  http://php.net/chr

To save that hard-working server a few machine cycles, one would presumably 
store ord(z) in a variable before the loop began and test for that each 
iteration.

Warm regards,
Paul


Paul:

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 
wasn't looking for a solution because I already had one.

What I was looking for was an explanation, which I got. I hope the answer 
remains with me longer than the bandages do. Asking questions in this group is 
like trying to feed alligators while being waist-deep in the swamp. :-)

Thanks.

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



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
   signed char, and that's implementation issue not a design issue.
 
  Actually it's a design issue. C uses a numeric datatype that is bound by
  a specific number of bits. It could just have well have been designed
  with a numeric datatype that had arbitrary length. The design decision
  was made to keep it close to the machine. However, the point I was
  making is that dealing with fringe cases is a necessity when you want to
  ensure your code is robust.
 
 
 I haven't thought this carefully, you're right to point that is a design
 issue since compilers and interpreters have to take into account the actual
 data representation in the design stage. Still, an overload is an known
 issue and that can be caught easily. If you assume that the ++ and
 comparison operator can be used with any type of object in a for loop, and
 they don't follow the expected contrains an iterator shoud have then the
 problem will be less apparent, as the issue is not considered a misuse but a
 normal function of the data type.

So there you go, by your own words, knowing the way the system works and
the edge cases is integral to proper use of the language. Thus when
'z'++ == 'aa' the semantics while not necessarily ubiquitous, fall under
the language's well defined modus operandi :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



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 
wasn't looking for a solution because I already had one.

What I was looking for was an explanation, which I got. I hope the answer 
remains with me longer than the bandages do. Asking questions in this group is like 
trying to feed alligators while being waist-deep in the swamp. :-)



Ah, got it.  You wanted one thing, but asked another to 'bait' people. 
Didn't like the explanation you got, thought you knew better, and 
dismissed it.  Got 'hurt' that people got tired of your badgering, and 
the list is mean to you?  Well, that's easily solved.  One more *plonk* 
in my killfile, and you'll have one less person to worry about being 
mean to you.


--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

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



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. That algorithm has an error, an
overflow
  on a
   signed char, and that's implementation issue not a design issue.
 
  Actually it's a design issue. C uses a numeric datatype that is bound
by
  a specific number of bits. It could just have well have been designed
  with a numeric datatype that had arbitrary length. The design decision
  was made to keep it close to the machine. However, the point I was
  making is that dealing with fringe cases is a necessity when you want
to
  ensure your code is robust.


 I haven't thought this carefully, you're right to point that is a design
 issue since compilers and interpreters have to take into account the
actual
 data representation in the design stage. Still, an overload is an known
 issue and that can be caught easily. If you assume that the ++ and
 comparison operator can be used with any type of object in a for loop,
and
 they don't follow the expected contrains an iterator shoud have then the
 problem will be less apparent, as the issue is not considered a misuse
but a
 normal function of the data type.

So there you go, by your own words, knowing the way the system works and
the edge cases is integral to proper use of the language. Thus when
'z'++ == 'aa' the semantics while not necessarily ubiquitous, fall under
the language's well defined modus operandi :)



You lost me there. Can you explain it a little bit further?


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 over since I posted the problem, but I 
wasn't looking for a solution because I already had one.

What I was looking for was an explanation, which I got. I hope the answer 
remains with me longer than the bandages do. Asking questions in this group 
is like trying to feed alligators while being waist-deep in the swamp. :-)


Ah, got it.  You wanted one thing, but asked another to 'bait' people. Didn't 
like the explanation you got, thought you knew better, and dismissed it.  Got 
'hurt' that people got tired of your badgering, and the list is mean to you?  
Well, that's easily solved.  One more *plonk* in my killfile, and you'll have 
one less person to worry about being mean to you.

--
John C. Nichel IV

John:

I hope you're not serious, are you?

The last thing I want to do is to offend or annoy anyone -- if I have done 
something wrong, please accept my most sincere apology.

When I said to bait, I meant to make the topic of interest -- much like a 
headline.

Are far as being beat-up, no one in this group has done anything that I found 
remotely offensive or objectionable. I said that to be humorous. Sorry, 
sometimes humor doesn't translate well without visual clues.

In any event, if anyone has found my comments or observations objectionable or 
annoying, please accept my apology.

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



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:
 
  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
 signed char, and that's implementation issue not a design issue.
   
Actually it's a design issue. C uses a numeric datatype that is bound
  by
a specific number of bits. It could just have well have been designed
with a numeric datatype that had arbitrary length. The design decision
was made to keep it close to the machine. However, the point I was
making is that dealing with fringe cases is a necessity when you want
  to
ensure your code is robust.
  
  
   I haven't thought this carefully, you're right to point that is a design
   issue since compilers and interpreters have to take into account the
  actual
   data representation in the design stage. Still, an overload is an known
   issue and that can be caught easily. If you assume that the ++ and
   comparison operator can be used with any type of object in a for loop,
  and
   they don't follow the expected contrains an iterator shoud have then the
   problem will be less apparent, as the issue is not considered a misuse
  but a
   normal function of the data type.
 
  So there you go, by your own words, knowing the way the system works and
  the edge cases is integral to proper use of the language. Thus when
  'z'++ == 'aa' the semantics while not necessarily ubiquitous, fall under
  the language's well defined modus operandi :)

 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 information about the overload to handle it.

It is a known issue in PHP that incrementing 'z' by 1 produces 'aa'

It follows that knowing that 'z' incremented by 1 produces 'aa' can be
caught easily.

It follows that if it can be caught easily, it can be handled easily.

Thus it finally follows your own words:

as the issue is not considered a misuse but a normal function
 of the data type

Normal in PHP is exactly the behaviour that PHP deemed many years ago
for it to follow.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



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:
 
 
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
 signed char, and that's implementation issue not a design issue.
   
Actually it's a design issue. C uses a numeric datatype that is
bound
  by
a specific number of bits. It could just have well have been
designed
with a numeric datatype that had arbitrary length. The design
decision
was made to keep it close to the machine. However, the point I was
making is that dealing with fringe cases is a necessity when you
want
  to
ensure your code is robust.
  
  
   I haven't thought this carefully, you're right to point that is a
design
   issue since compilers and interpreters have to take into account the
  actual
   data representation in the design stage. Still, an overload is an
known
   issue and that can be caught easily. If you assume that the ++ and
   comparison operator can be used with any type of object in a for
loop,
  and
   they don't follow the expected contrains an iterator shoud have then
the
   problem will be less apparent, as the issue is not considered a
misuse
  but a
   normal function of the data type.
 
  So there you go, by your own words, knowing the way the system works
and
  the edge cases is integral to proper use of the language. Thus when
  'z'++ == 'aa' the semantics while not necessarily ubiquitous, fall
under
  the language's well defined modus operandi :)

 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 information about the overload to handle it.

It is a known issue in PHP that incrementing 'z' by 1 produces 'aa'

It follows that knowing that 'z' incremented by 1 produces 'aa' can be
caught easily.

It follows that if it can be caught easily, it can be handled easily.

Thus it finally follows your own words:

as the issue is not considered a misuse but a normal function
 of the data type

Normal in PHP is exactly the behaviour that PHP deemed many years ago
for it to follow.



Thanks, I got it now.

What I meant as known issue is that the program is notified of the
occurrence of such problem. When the 'z' is incremented into 'aa' you're
stepping back in the sequence order but nothing is said or notified in any
way. The coder who explicitly wants to use such feature may handle the issue
without a problem, but when you work on the basis that you can receive any
kind of sequence, range, or iterator you can't know for sure that this
happens. Consider this example:

function orderedSequence($start, $end) {
   $orderedSequence = array();
   for ($i = $start; $i = $end; $i++) {
   $orderedSequence[] = $i;
   }
   return $orderedSequence;
}

Supposedly this function would return an ordered sequence of objects, which
implement iteration, between $start and $end. Under the mentioned
circumstances the function would fail to return an ordered sequence. Still,
this kind of generic behaviour it something that isn't useful in PHP,
since there isn't operator overloading. Anyway PHP5 has some features that
point that generics will be used (correct if i'm wrong here, that's what I
thought when I saw iterators in the SPL) and I think that we won't be able
to use native operators to create proper iterators on strings with the
current functionality assigned to them.

Well, my arguments are starting to sound much more like ranting that
anything else. Sorry if they weren't appropiate.


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 information about the overload to handle it.
 
  It is a known issue in PHP that incrementing 'z' by 1 produces 'aa'
 
  It follows that knowing that 'z' incremented by 1 produces 'aa' can be
  caught easily.
 
  It follows that if it can be caught easily, it can be handled easily.
 
  Thus it finally follows your own words:
 
  as the issue is not considered a misuse but a normal function
   of the data type
 
  Normal in PHP is exactly the behaviour that PHP deemed many years ago
  for it to follow.
 
 
 Thanks, I got it now.
 
 What I meant as known issue is that the program is notified of the
 occurrence of such problem. When the 'z' is incremented into 'aa' you're
 stepping back in the sequence order but nothing is said or notified in any
 way. The coder who explicitly wants to use such feature may handle the issue
 without a problem, but when you work on the basis that you can receive any
 kind of sequence, range, or iterator you can't know for sure that this
 happens. Consider this example:
 
 function orderedSequence($start, $end) {
 $orderedSequence = array();
 for ($i = $start; $i = $end; $i++) {
 $orderedSequence[] = $i;
 }
 return $orderedSequence;
 }
 
 Supposedly this function would return an ordered sequence of objects, which
 implement iteration, between $start and $end. Under the mentioned
 circumstances the function would fail to return an ordered sequence. Still,
 this kind of generic behaviour it something that isn't useful in PHP,
 since there isn't operator overloading. Anyway PHP5 has some features that
 point that generics will be used (correct if i'm wrong here, that's what I
 thought when I saw iterators in the SPL) and I think that we won't be able
 to use native operators to create proper iterators on strings with the
 current functionality assigned to them.
 
 Well, my arguments are starting to sound much more like ranting that
 anything else. Sorry if they weren't appropiate.

No problem, doesn't really sound like ranting to me. But I think the
main problem some people are having is understanding that there are two
sequences in question here and not one. There is the sequence generated
by the incrementation operator, and there is the sequence of all
possible strings in their sorted order. Combining the semantics of the
two sequences does not necessarily leave you with the semantics of one
or the other.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



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
  aa
  ab
  ac
   .
   .
   .
  ax
  ay
  az
  ba
  bb
  bc
   .
   .
   .
 aaa
   .
   .
   .
 zzz

   .
   .
   .

   .
   .
   .

   .
   .
   .


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.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



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
   z
  aa
  ab
  ac
   .
   .
   .
  ax
  ay
  az
  ba
  bb
  bc
   .
   .
   .
 aaa
   .
   .
   .
 zzz

   .
   .
   .

   .
   .
   .

   .
   .
   .


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



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 sequence, like  then the ++ does nothing.  So ++ stays at 
 .  However 3 becomes 4 and b++ becomes c.  99z++ 
 becomes 100a and

Funky stuff.

  1z9z9z++ becomes 2a0a0a and yes, of course z++ 

Good thing Tedd didn't come across the above one by accident *lol*.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



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 giving was File1++ == File2 or 
FileA++ == FileB.  In that case, wouldn't you want it to go from FileZ to 
FileAA?  Makes sense right?

2. Comparing greatness of strings:  Rasmus mentioned this earlier, but I 
wante to illustrate it a little more because I think it was overlooked.  If you 
have a list of names, for instance, and you alphabetize them, you'd get 
something like this:

Bob
Brendan
Burt
Frank
Fred

Just become a name is longer doesn't mean it comes after the rest of the names 
in the list.  So in that vane, anything starting in A will never be  
something starting with a Z.  a  z  aa  z  aaa  z because:

a
aa
aaa
z

When using interation and a for loop and  = z it gets to y and it's true, 
gets to z and it's still true, then increments to az and yup.. still  z. 
 As mentioned, it's not until you get to something starting in z with 
something after it that you're  z.

So hopefully that makes a little more sense.

-TG



= = = Original message = = =

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 ($i=a; $i=z; $i++)
   
   echo($i);

 
 -- not continue past aaa? Clearly, if aaa is less than z then why does 
 the loop stop at yz?

I thought I explained that a few times.  The sequence is:

a b c ... x y z aa ab ac ... yx yy yz za zb zc ... zy zx zz aaa aab

Your loop stops at yz and doesn't get anywhere near aaa because za  z

-Rasmus


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



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 to see what would happen.

Okay, so I found out it's limitations and quirks.

But, you must admit that it is confusing to have a loop that goes from a to 
z and considers aa but not aaa.

Now, if the loop just went from a to z, then I would think that would be 
logical. But I fail to see the logic behind considering aa but not aaa in 
the evaluation. But then again, I'm not that informed.

Enough said.

tedd



At 12:21 PM -0400 6/5/06, [EMAIL PROTECTED] wrote:
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 giving was File1++ == File2 or 
FileA++ == FileB.  In that case, wouldn't you want it to go from FileZ to 
FileAA?  Makes sense right?

2. Comparing greatness of strings:  Rasmus mentioned this earlier, but I 
wante to illustrate it a little more because I think it was overlooked.  If 
you have a list of names, for instance, and you alphabetize them, you'd get 
something like this:

Bob
Brendan
Burt
Frank
Fred

Just become a name is longer doesn't mean it comes after the rest of the names 
in the list.  So in that vane, anything starting in A will never be  
something starting with a Z.  a  z  aa  z  aaa  z because:

a
aa
aaa
z

When using interation and a for loop and  = z it gets to y and it's true, 
gets to z and it's still true, then increments to az and yup.. still  
z.  As mentioned, it's not until you get to something starting in z with 
something after it that you're  z.

So hopefully that makes a little more sense.

-TG



= = = Original message = = =

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 ($i=a; $i=z; $i++)
  
   echo($i);
   

 -- not continue past aaa? Clearly, if aaa is less than z then why does 
 the loop stop at yz?

I thought I explained that a few times.  The sequence is:

a b c ... x y z aa ab ac ... yx yy yz za zb zc ... zy zx zz aaa aab

Your loop stops at yz and doesn't get anywhere near aaa because za  z

-Rasmus


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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


-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



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 a lark just to see what would happen.

Okay, so I found out it's limitations and quirks.

But, you must admit that it is confusing to have a loop that goes from a to z and considers 
aa but not aaa.

Now, if the loop just went from a to z, then I would think that would be logical. But I fail to see 
the logic behind considering aa but not aaa in the evaluation. But then 
again, I'm not that informed.

Enough said.

tedd



At 12:21 PM -0400 6/5/06, [EMAIL PROTECTED] wrote:

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 giving was File1++ == File2 or FileA++ == 
FileB.  In that case, wouldn't you want it to go from FileZ to FileAA?  Makes sense right?

2. Comparing greatness of strings:  Rasmus mentioned this earlier, but I 
wante to illustrate it a little more because I think it was overlooked.  If you have a 
list of names, for instance, and you alphabetize them, you'd get something like this:

Bob
Brendan
Burt
Frank
Fred

Just become a name is longer doesn't mean it comes after the rest of the names in the list.  So in that vane, 
anything starting in A will never be  something starting with a Z.  a  z  aa 
 z  aaa  z because:

a
aa
aaa
z

When using interation and a for loop and  = z it gets to y and it's true, gets to z and it's still true, then 
increments to az and yup.. still  z.  As mentioned, it's not until you get to something starting in z with something 
after it that you're  z.

So hopefully that makes a little more sense.

-TG



= = = Original message = = =

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 ($i=a; $i=z; $i++)
 
  echo($i);
  


-- not continue past aaa? Clearly, if aaa is less than z then why does the loop 
stop at yz?

I thought I explained that a few times.  The sequence is:

a b c ... x y z aa ab ac ... yx yy yz za zb zc ... zy zx zz aaa aab

Your loop stops at yz and doesn't get anywhere near aaa because za  z

-Rasmus


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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





As mentioned before, discussion aside, you can do what you want with 
range and a foreach:


foreach (range('a', 'z') as $char)
{
   echo $char;
}

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



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 other languages, I just tried 
 it on a lark just to see what would happen.
 
 Okay, so I found out it's limitations and quirks.
 
 But, you must admit that it is confusing to have a loop that goes from a to 
 z and considers aa but not aaa.
 
 Now, if the loop just went from a to z, then I would think that would be 
 logical. But I fail to see the logic behind considering aa but not aaa in 
 the evaluation. But then again, I'm not that informed.
 
 Enough said.

NO! More must be said!!

a   = z
b   = z
c   = z
...
y   = z
z   = z
aa  = z
ab  = z
ac  = z
...
az  = z
ba  = z
bb  = z
bc  = z
...
cz  = z
...
dz  = z
...
...
...
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 test fails and the loop stops.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



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 valid choices 
among many ways that it could have been handled.

From a developers point of view it becomes it is what it is.  Now 
understanding the nature of the beast we must accept that this is just how PHP 
works.  It's not wrong, it's just strange when it comes to z++ combined with a 
for loop.  Probably an unforeseen disconnect when designing PHP but the most 
important thing is understanding HOW it works (more so than 'why' it was 
designed that way) and coding accordingly.

There are many other ways to accomplish an A-Z sequence so as long as what's 
been discussed is understood as just how PHP is, and that it's logical for 
certain purposes, then we can choose one of the other choices for solving the 
problem.


-TG

= = = Original message = = =

-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 to see what would happen.

Okay, so I found out it's limitations and quirks.

But, you must admit that it is confusing to have a loop that goes from a to 
z and considers aa but not aaa.

Now, if the loop just went from a to z, then I would think that would be 
logical. But I fail to see the logic behind considering aa but not aaa in 
the evaluation. But then again, I'm not that informed.

Enough said.

tedd



___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



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 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?


From a developers point of view it becomes it is what it is.  Now
understanding the nature of the beast we must accept that this is just how
PHP works.  It's not wrong, it's just strange when it comes to z++ combined
with a for loop.  Probably an unforeseen disconnect when designing PHP but
the most important thing is understanding HOW it works (more so than 'why'
it was designed that way) and coding accordingly.



I agree, this is what we have and what we asked for, we wanted to use
strings on a math context and these things are bound to happen. But still
saying that something is right/wrong/not right/not wrong in CS is a bold
statement. On a certain context something may seem right but when the
context changes it turns out to be wrong, for example suppose we have a
programming language that handles strings the way PHP does, and it
implements templates or generics (the term you prefer the most). The
template/generic should have to be aware of strings when using math
operators, because they don't behave the way a math literal would.

There are many other ways to accomplish an A-Z sequence so as long as what's

been discussed is understood as just how PHP is, and that it's logical for
certain purposes, then we can choose one of the other choices for solving
the problem.



I don't think it's only about us as developers using PHP, but us as
community giving back something to the community. This might be a small
issue but what would be the whole point of being an open-source community if
we can't at least discuss about it? It just the way things are is not an
argument, it's an excuse.

-TG





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 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?

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



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 test fails and the loop stops.

Cheers,
Rob.


Rob:

Okay, I tried to get out of it, but I guess more must be said.

I do understand why the loop stops -- I totally understand the mechanics. After 
all this, how could I not? Besides, it's really not that difficult, is it? So, 
what might you guess I'm really talking about?

You see, what is failing to be understood here is what I'm addressing, which is 
basic set theory. One of the basic foundations for mathematics

If I have a set that is defined as all elements  whatever and  something 
else, then you can address the set. You can ask questions about the set, such 
as what's the population of the set -- besides itself, does the set have any 
subsets, and such -- get the idea?

Now, if you have a set [A] where all elements within are defined as (a or 
greater) and (less than z) -- then, believe or not, that set is infinite -- 
as is the set for everything  z.

If you choose, which is the case here, to consider only a subset of [A], then 
that's fine -- but understand that when you say the sequence is --

a b c ... x y z aa ab ac ... yx yy yz za zb zc ... zy zx zz aaa aab

-- it's not!

But rather, the actual sequence is:

a b c ... x y z aa ab ac ... yx yy yz aaa aab aac... infinite z

You simply have chosen to arbitrarily end the sequence at yz. That's the 
reason why aaa is less than z but not included in the php-loop set of 
(for i=a to z).

You can't say that a and aaa are members of a set identified as  z and 
then step through all the members of that population (an infinite group) and 
not include aaa -- UNLESS -- you arbitrarily determine an end point for a 
much smaller sub-set.

Now, unless, there is something that I don't see, which certainly could be the 
case, then php designers could have just as easily ended the loop at z and 
dispensed with this quirk all together.

Besides, what's the point of having 676 character between a and z? Is there 
one? I think the accepted number would be closer to 26, don't you think? It 
just seems more like common sense to me -- doesn't it to you?

But this is the way it is and I except that -- but as Dirty Harry once said A 
man's got to know his limitations -- this not only applies to men and 
programmers, but also for languages as well.

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 only guess at 
what's going to happen when we start considering 00-FF code-points.

Now, was that enough said?  :-)

Cheers.

tedd

-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



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 only guess at 
what's going to happen when we start considering 00-FF code-points.

Now, was that enough said?  :-)


I don't think you really understand this.   and  are collation 
operators when they operate on strings.  They have absolutely nothing to 
do with the numeric values of the characters.  It just so happens that 
in English iso-8859-1 there is a 1:1 relationship between the numeric 
values and the collation order, but you can think of that as dumb luck.


To better understand this, I suggest you start reading here:

  http://icu.sourceforge.net/userguide/Collate_Intro.html

Note one of the points on that page.  That in Lithuanian 'y' falls 
between 'i' and 'k'.  So even without going into Unicode and just using 
low-ascii, you have these issues.


Now, until we get to PHP 6, we don't have decent Unicode support and we 
don't have LOCALE-aware operators.  You will have to manually use 
strcoll() to get them, but that is going to change and you will have the 
ICU collation algorithms available and for Unicode strings it will be 
automatic.  You can still have binary-strings if you don't want 
locale-aware collation, of course.


-Rasmus

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



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. za is the last comparison to occur at which
 point the test fails and the loop stops.
 
 Cheers,
 Rob.
 
 
 Rob:
 
 Okay, I tried to get out of it, but I guess more must be said.
 
 I do understand why the loop stops -- I totally understand the mechanics. 
 After all this, how could I not? Besides, it's really not that difficult, is 
 it? So, what might you guess I'm really talking about?
 
 You see, what is failing to be understood here is what I'm addressing, which 
 is basic set theory. One of the basic foundations for mathematics
 
 If I have a set that is defined as all elements  whatever and  something 
 else, then you can address the set. You can ask questions about the set, 
 such as what's the population of the set -- besides itself, does the set have 
 any subsets, and such -- get the idea?
 
 Now, if you have a set [A] where all elements within are defined as (a or 
 greater) and (less than z) -- then, believe or not, that set is infinite -- 
 as is the set for everything  z.
 
 If you choose, which is the case here, to consider only a subset of [A], then 
 that's fine -- but understand that when you say the sequence is --
 
 a b c ... x y z aa ab ac ... yx yy yz za zb zc ... zy zx zz aaa aab
 
 -- it's not!
 
 But rather, the actual sequence is:
 
 a b c ... x y z aa ab ac ... yx yy yz aaa aab aac... infinite z
 
 You simply have chosen to arbitrarily end the sequence at yz. That's the 
 reason why aaa is less than z but not included in the php-loop set of 
 (for i=a to z).
 
 You can't say that a and aaa are members of a set identified as  z and 
 then step through all the members of that population (an infinite group) and 
 not include aaa -- UNLESS -- you arbitrarily determine an end point for a 
 much smaller sub-set.
 
 Now, unless, there is something that I don't see, which certainly could be 
 the case, then php designers could have just as easily ended the loop at z 
 and dispensed with this quirk all together.
 
 Besides, what's the point of having 676 character between a and z? Is there 
 one? I think the accepted number would be closer to 26, don't you think? It 
 just seems more like common sense to me -- doesn't it to you?
 
 But this is the way it is and I except that -- but as Dirty Harry once said 
 A man's got to know his limitations -- this not only applies to men and 
 programmers, but also for languages as well.
 
 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 only guess at 
 what's going to happen when we start considering 00-FF code-points.
 
 Now, was that enough said?  :-)

ABSOLUTELY NOT! *bahahahahah*

You gotta stop smoking the ganja Tedd, it's slowing your synapses.

No there are not 676 character combinations less than z. There are an
infinite number. a, aa, aaa, , a, a, ... ab, aab, aaab,
b, ..., INFINITE. You are incrementing, this follows rules of
incrementation and so incrementing +1 at a time as defined for strings
in PHP causes you to only see 676 of the combinations less than z. It's
like having 1.0 and incrementing it .5 each time, and saying WTF, why
are there only 19 entries less than or equal to 10? There aren't, there
are an infinite number of values between 1.0 and 10 but we the rule sof
incrementation in this case skip past them.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



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 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?

Maybe to you, but not me.

In my book, you can't add a positive value to z and produce something that is 
less than z.

For example, aa is not greater than z -- is it?

Besides, what value are we adding? There is no incremental character in 
strings and adding two characters doesn't evaluate to anything.

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.

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



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 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?


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 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?
 
 Maybe to you, but not me.
 
 In my book, you can't add a positive value to z and produce something that is 
 less than z.
 
 For example, aa is not greater than z -- is it?

If I remember my abstract algebra correctly, the modulus operator forms
a set for any given value right operand. Interestingly then taking the
set of x%10 we find that adding 1 to x when x is 9 is indeed less than
9.

I'm sure I could summarize this better if I could remember my abstract
algebra and spaces *lol*. I remember vaguely proving spaces and stuff
based on various properties.

Either way the above exmaple gives a simple case where your assertion
also fails, and this is in the world of general mathematics.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



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 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?

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 useful to deal with strings as strings than to make 
them quack like numbers.

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



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 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?

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 useful to deal with strings as strings than to make
them quack like numbers.



Then, if it's not a math operation, why use a math operator for such
functionality? In which way is the ++ operator that generates a string
sequence, useful enough to justify the formal inconsistency between the math
operators? I still don't see the advantages of having the ++ recognize the
string as a sequence, and generate the next item in the sequence. I believe
those decisions should be left to the coder, because he knows what the
string really represents and which kind of sequence is being used.


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 useful to deal with strings as strings than to make
  them quack like numbers.
 
 
 Then, if it's not a math operation, why use a math operator for such
 functionality? In which way is the ++ operator that generates a string

I don't ever remember seeing ++ in math class. I do remember seeing it
in lots of computer classes and to that end it was just an operator
with whatever semantic meaning was applied to it for a given language. I
guess it's usually to increment an integer, but that's just in
general. I mean if we want to get into math operators being used for
string purposes, then we should look at how many languages use the +
operator to concatenate two strings -- by your accounts they should
treat their operands as integers and do a rote addition.

 sequence, useful enough to justify the formal inconsistency between the math
 operators? I still don't see the advantages of having the ++ recognize the
 string as a sequence, and generate the next item in the sequence. I believe
 those decisions should be left to the coder, because he knows what the
 string really represents and which kind of sequence is being used.

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, and IMHO the best
choice. For such a fringe issue I don't see what the argument is all
about. If you want the functionality you get in C by incrementing a
char, then use the chr() function on an integer.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



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

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 all, when $i = z 
in the first expression, then wouldn't $i be equal to z in the second expression and thus halt 
the operation?

What am I missing here?


It's a bit of a quirk.  z++ is aa and aa  z.  I would guess 
this would loop until until just before za which would be yz.


It's a bit like looping through the hexadecimal characters.  You would 
have the same effect.  However instead of being base-16 with 0-9-a-f you 
have base-26 using a-z.


-Rasmus

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



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; $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?

 Just stopping at z would seem to make more sense, wouldn't it? After
all, when $i = z in the first expression, then wouldn't $i be equal to z
in the second expression and thus halt the operation?

 What am I missing here?

It's a bit of a quirk.  z++ is aa and aa  z.  I would guess
this would loop until until just before za which would be yz.



What?
z++  z returns true? =S
Is there a reason for this? Why aren't they handled like C chars?

It's a bit like looping through the hexadecimal characters.  You would

have the same effect.  However instead of being base-16 with 0-9-a-f you
have base-26 using a-z.



0xF++  would be 0x10 which is greater than 0xF (0xF  0x10). It's not the
same.

-Rasmus


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




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 uses --

 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?

 Just stopping at z would seem to make more sense, wouldn't it? After
all, when $i = z in the first expression, then wouldn't $i be equal 
to z

in the second expression and thus halt the operation?

 What am I missing here?

It's a bit of a quirk.  z++ is aa and aa  z.  I would guess
this would loop until until just before za which would be yz.



What?
z++  z returns true? =S
Is there a reason for this? Why aren't they handled like C chars?


Because PHP is not C.  If you want them handled by their char codes, 
then do so with chr() calls.



It's a bit like looping through the hexadecimal characters.  You would

have the same effect.  However instead of being base-16 with 0-9-a-f you
have base-26 using a-z.



0xF++  would be 0x10 which is greater than 0xF (0xF  0x10). It's not the
same.


Sure it is.  If you treat 0x10 as a string the same way he is treating 
these as strings, then 0x10 is going to be smaller than 0xF.


The fact is that there is just no right answer for what z++ should do.

-Rasmus

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



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,
 but
 can't find the reference.
 
  In any event, if one uses --
 
  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?
 
  Just stopping at z would seem to make more sense, wouldn't it?
After
 all, when $i = z in the first expression, then wouldn't $i be equal
 to z
 in the second expression and thus halt the operation?
 
  What am I missing here?

 It's a bit of a quirk.  z++ is aa and aa  z.  I would guess
 this would loop until until just before za which would be yz.


 What?
 z++  z returns true? =S
 Is there a reason for this? Why aren't they handled like C chars?

Because PHP is not C.  If you want them handled by their char codes,
then do so with chr() calls.



That's cool, but you missed my point, I was just wondering why the ++
operator for string was handled that way. I used the C comparison becuase
it's more usual for coders to think as chars in terms of their position in
the ASCII table, allowing loops such as the mentioned above. I'm not trying
to start another witch hunt, there are enough rantings around for that
purpose.


It's a bit like looping through the hexadecimal characters.  You would
 have the same effect.  However instead of being base-16 with 0-9-a-f
you
 have base-26 using a-z.


 0xF++  would be 0x10 which is greater than 0xF (0xF  0x10). It's not
the
 same.

Sure it is.  If you treat 0x10 as a string the same way he is treating
these as strings, then 0x10 is going to be smaller than 0xF.

The fact is that there is just no right answer for what z++ should do.

-Rasmus



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)


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 all, 
when $i = z in the first expression, then wouldn't $i be equal to z in 
the second expression and thus halt the operation?

What am I missing here?

It's a bit of a quirk.  z++ is aa and aa  z.  I would guess this 
would loop until until just before za which would be yz.

It's a bit like looping through the hexadecimal characters.  You would have 
the same effect.  However instead of being base-16 with 0-9-a-f you have 
base-26 using a-z.

-Rasmus

-Rasmus:

Ahhh -- I see -- sort of.

However, if it has to be a base then it's more like base-676, going from a to 
yz. Like DEC has 10 elements and HEX has 16 elements, this has 676 elements.

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.

Shouldn't the expression $i =z be true when $i=z and if $i is greater, then 
be false?

For example, please review:

http://xn--ovg.com/a1.php

You can here that when $i = z, then the condition is true and it prints 
Look. One would think that anything greater than that point would be false 
and thus end the loop. But here we have an example of how we can have something 
equal to something and then by adding 1 to it, it becomes smaller. That's not 
logical.

Furthermore, if it was to work like a base, then I would expect z to the the 
last character, not the 26th.

Here's another way to look at it. All characters before z are less than z 
-- correct? So, what value are all characters after z (i.e., aa-yz)? They 
cannot be greater than, nor can they be less than. So, what are they?

tedd

PS: It was just a day, or so ago, that I said I didn't want disagree with you 
and now what have you got me into? running for cover looking for rock to 
program with
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



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 obviously continue because y  z
When $i = z it will obviously continue because z = z
When $i = aa it will obviously continue because aa  z

It doesn't stop until you get to z+something.  As in za because at 
that point za  z so the last thing you see is the one before za 
which would be yz.



Here's another way to look at it. All characters before z are less than z -- correct? So, what 
value are all characters after z (i.e., aa-yz)? They cannot be greater than, nor can they be 
less than. So, what are they?


But you are not comparing things in the same context here.  Strings are 
naturally compared alphabetically while you are thinking they are 
compared numerically somehow.  Think of sorting a set of words.  Would 
you expect aa to sort before or after z ?


So yes, like I said, it is a bit of a quirk, but there is no good answer 
to what z++ should be and we certainly don't want to change the 
default comparison mechanism to not compare strings alphabetically 
because that would screw up all sorts of stuff including usorts and 
peoples' expectations.  It's just in this case where you have gotten it 
into your head that incrementing strings is a good thing to do.


You'd be much better off with a range call to quickly generate a range 
of characters.  You could then loop through that character by character. 
 Or use the chr() function to work with character codes instead.


-Rasmus

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



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 the user expects.  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 the amount of code you 
would need to write in C to make that work?


Then change $filename to fileA and increment it.  And you get fileB. 
 When we get to fileZ we don't want to go off into unprintable 
character land, we want to try to stick with the pattern.


-Rasmus

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



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.  Operators have to
guess at the type and try to do what the user expects.  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 the amount of code you
would need to write in C to make that work?

Then change $filename to fileA and increment it.  And you get fileB.
  When we get to fileZ we don't want to go off into unprintable
character land, we want to try to stick with the pattern.

-Rasmus



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 string is really representing, not to the
language.


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 string is really representing, 
not to the language.


That's the strictly typed argument.  If you always force people to 
declare their types and you never automatically convert them, then you 
have a strictly typed language.  You have the same thing happening for 
something like:


 echo 2+3;

In a strictly typed language that would spew an error.  In a loosely 
typed language like PHP you get 5


And yes, I agree that ++ on strings is getting near the edge of that, 
but there has to be an edge somewhere and not everyone is going to agree 
on exactly where to draw the line.


-Rasmus

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



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 to continue is $i=z.

[1] When $i = y it will obviously continue because y  z
[2] When $i = z it will obviously continue because z = z
[3] When $i = aa it will obviously continue because aa  z

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.

It doesn't stop until you get to z+something.  As in za because at that 
point za  z so the last thing you see is the one before za which would 
be yz.

See above -- plus, I would expect that in evaluating a character, that 
character(s) would not enter the mix. If I was to evaluate a single digit, it 
would seem odd if double digits were allowed in that evaluation.

Here's another way to look at it. All characters before z are less than z 
-- correct? So, what value are all characters after z (i.e., aa-yz)? They 
cannot be greater than, nor can they be less than. So, what are they?

But you are not comparing things in the same context here.  Strings are 
naturally compared alphabetically while you are thinking they are compared 
numerically somehow.  Think of sorting a set of words.  Would you expect aa 
to sort before or after z ?


Not meaning to infer that you don't know this, because I know you do -- so I 
must be confused.

Yes, it is my contention that strings are numerical -- you don't store A in 
memory, you store 0100 001, or ASCII DEC 65.

Likewise a is DEC 97 (0110 0001) and z is DEC 122 (0111 1010) and if I 
compare a to z , it will always be less by numeric definition.

However, if I compare aa with z, then what? Is the numerical translation of 
the strings --

0110 0001 0110 0001  0111 1010

equal to TRUE -- I don't think so.

Likewise, is the string aaa greater than z -- yep, I can buy that. But, if 
you hold that aa is less than z, then everything must be less than z 
(except z stuff). So, the loop would continue until you hit the maximum 
allowable for strings -- that doesn't sound good.

I can't see the logic that says aa is less than z while aaa is greater. 
That sounds like something our government would dream up.

So yes, like I said, it is a bit of a quirk, but there is no good answer to 
what z++ should be and we certainly don't want to change the default 
comparison mechanism to not compare strings alphabetically because that would 
screw up all sorts of stuff including usorts and peoples' expectations.  It's 
just in this case where you have gotten it into your head that incrementing 
strings is a good thing to do.

Oh, I'm not saying to change anything. I've seen and worked with worse.

You'd be much better off with a range call to quickly generate a range of 
characters.  You could then loop through that character by character.  Or use 
the chr() function to work with character codes instead.

I figured a way around it, I just thought it was odd.

Thanks for your insight.

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



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
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



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 condition for the loop to continue is $i=z.

[1] When $i = y it will obviously continue because y  z
[2] When $i = z it will obviously continue because z = z
[3] When $i = aa it will obviously continue because aa  z


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


Not meaning to infer that you don't know this, because I know you do -- so I 
must be confused.

Yes, it is my contention that strings are numerical -- you don't store A in 
memory, you store 0100 001, or ASCII DEC 65.

Likewise a is DEC 97 (0110 0001) and z is DEC 122 (0111 1010) and if I compare a to 
z , it will always be less by numeric definition.

However, if I compare aa with z, then what? Is the numerical translation of 
the strings --

0110 0001 0110 0001  0111 1010

equal to TRUE -- I don't think so.


No, but we are talking about collation here, not representation.

Likewise, is the string aaa greater than z -- yep, I can buy that. 


Well, it isn't.  So the bulk of your rant is rather meaningless.

-Rasmus

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



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; $i++)
  {
  echo($i);
   }

-- not continue past aaa? Clearly, if aaa is less than z then why does 
the loop stop at yz?

In any event, I'll stop my rant now, I thought we were having a discussion.

tedd

-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



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
 
 You missed the point, why does --
 
 for ($i=a; $i=z; $i++)
   {
   echo($i);
}
 
 -- 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'.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



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 equal to 'z' :B

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



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  = 0;
char c = 0x00;
char t = 0x00;

for( i = 0; i  129; i++ )
{
t = c;
++c;

if( t  c )
{
printf( Less than!\n );
}
else
{
printf( Not less than!\n );
}
}

return 0;
}

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



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 and other high-level languages, strings are their own datatype.  They 
may or may not even be stored as standard ascii number codes in order 
internally.  You have to think of them as strings, not as numbers.  There are 
no numbers involved here.  There are only strings.  

 Likewise a is DEC 97 (0110 0001) and z is DEC 122 (0111 1010) and if I
 compare a to z , it will always be less by numeric definition.

In C or C++, yes.  In PHP, do not assume the same string-number mapping.  
Numeric definition is irrelevant.

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.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 the
 amount of code you  would need to write in C to make
that work?
 
 Then change $filename to fileA and increment it. 
 And you get fileB. 
   When we get to fileZ we don't want to go off
 into unprintable 
 character land, we want to try to stick with the
 pattern.

/clip

Hmmm, didnt know about the $filename++; thingy, I used
to do things the hard (C) way. 
Learnt something new...thanks!

Cheers,
Ryan

--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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



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 6/4/06, Larry Garfield wrote:
On Sunday 04 June 2006 15:04, tedd wrote:
 Likewise a is DEC 97 (0110 0001) and z is DEC 122 (0111 1010) and if I
 compare a to z , it will always be less by numeric definition.

In C or C++, yes.  In PHP, do not assume the same string-number mapping. 
Numeric definition is irrelevant.

It's a sign of genius to make the complicated simple. Learning new things about 
php every day.

Thank you both.

tedd

PS: Great language. -- thanks Lerdorf.
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



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 ($i=a; $i=z; $i++)
  {
  echo($i);
   }

-- not continue past aaa? Clearly, if aaa is less than z then why does the loop 
stop at yz?


I thought I explained that a few times.  The sequence is:

a b c ... x y z aa ab ac ... yx yy yz za zb zc ... zy zx zz aaa aab

Your loop stops at yz and doesn't get anywhere near aaa because za  z

-Rasmus

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



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 map to a symbol.


In PHP and other high-level languages, strings are their own datatype.  They 
may or may not even be stored as standard ascii number codes in order 
internally.  You have to think of them as strings, not as numbers.  There are 
no numbers involved here.  There are only strings.  


Likewise a is DEC 97 (0110 0001) and z is DEC 122 (0111 1010) and if I
compare a to z , it will always be less by numeric definition.


In C or C++, yes.  In PHP, do not assume the same string-number mapping.  
Numeric definition is irrelevant.


Right, and now bring Unicode into the picture and this becomes even more 
true.


-Rasmus

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