| 
	
 | 
 Posted by Jochem Maas on 07/29/05 11:14 
Marcus Bointon wrote: 
> 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  
 
so called zvals (zend value) and indeed typehinting these in php would 
be silly. 
 
> 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! 
 
not unless you put a gun to my head ;-) 
 
>  
> Another point is that exception handling (another PHP5 feature) is  next  
> to useless without type hinting, so they HAD to implement it for   
 
that never crossed my mind! 
 
> objects so that catch clauses could work properly. 
>  
> Marcus
 
  
Navigation:
[Reply to this message] 
 |