Re: When is "z" != "z" ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
larry@xxxxxxxxxxxxxxxx		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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux