Am Mittwoch, 5. Juni 2002 10:44 schrieb Ilker Cetinkaya:
> >   Nice, but why not overload + for strings to do the
> > concatenation?
>
> i totally agree, overloading + for string concat is really
> desireable.

No, it is a nightmare.

PHP is a dynamically typed language, that is, the actual language 
objects know their type, while object names (variable 
identifiers) are untyped. Also, PHP automatically changes types 
of language objects as needed.

Consequently, most developers do not know the actual type of 
their variables (it is not seen anywhere unless you specifically 
ask for it), and most of the time they don't actually care for 
it. For example, when was the last time you noticed or even 
cared that all arguments of your program (_GET, _POST, _COOKIE) 
are actually string type, even if they are pure numeric strings?

Overloading + would suddenly require that developers care about 
type, and would force them to write expressions like

        $c = $a . $b;

as

        $c = (string) $a + (string) $b;

just to make sure. Not actually an improvement.


This actually a deeper problem, as we have seen in the last few 
discussions here on the list. PHP may remotely resemble C, C++ 
or even Java. It isn't. And it isn't intended to be.

If you treat it like any of these statically typed, compiled, and 
far more traditional languages, you bleed. Big time.

Actually, I believe that Javascript has the programming and 
execution model that comes closest to PHP of all the "C 
lookalike" languages.

Kristian


--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to