On 29 Jul 2005, at 08:19, Jochem Maas wrote:

unless String is a class you defined that won't work at all. basic data types
cannot be hinted (e.g. bool, int, string, float)

There's been quite a bit about this on php-internals. It seems to be because PHP doesn't differentiate between these types internally; they all seem to be classified as a generic scalar type whose actual type is determined according to context. Java can go to the other extreme, where every simple type is an object, and hence it's easy (if not mandatory) to specify types like this. You would never be able to say 'print "2" + 2' in Java and expect to get "4". This looseness is very much part of what makes PHP so easy to get into - if you really want these kind of features, you can just use Java instead!

Another point is that exception handling (another PHP5 feature) is next to useless without type hinting, so they HAD to implement it for objects so that catch clauses could work properly.

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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

Reply via email to