""Richard Quadling"" <[EMAIL PROTECTED]> schreef in bericht 
news:[EMAIL PROTECTED]
> On 13/09/06, Terje Slettebø <[EMAIL PROTECTED]> wrote:
..........
> The issue then becomes what would happen to a value of the wrong type?
>
> You either have the option of using PHP's own internal casting
> mechanism, so f(int $i_int_expected) would internally cast the
> supplied parameter as an int or you have to produce a WARNING with a
> "parameter of the wrong type" message. But then what is passed to the
> function? This would have to be determined somehow.

I think it would make sense to turn the value into NULL when the casting 
fails. And honestly, I would love this kind of type hinting. It has to be 
smart in the sense that if I say "double", and it's a string containing 
"0.123", it will either be casted to a double (which may be unfortunate, 
since floats and doubles are inaccurate), or simply let through as a string, 
because it follows double formatting (that being /-?[0-9]+(\.[0-9]+)?/). But 
this way type hinting for core types is only optional for people and it's 
not as strict as in the vast majority of other languages out there. This 
kind of smart type hinting would be simply perfect.

Ron 

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

Reply via email to