2006/6/6, Rasmus Lerdorf <rasmus@xxxxxxxxxxx>:
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.