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

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

 



2006/6/6, Larry Garfield <larry@xxxxxxxxxxxxxxxx>:

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.

[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