On Wed, September 13, 2006 6:01 am, Richard Quadling 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.

Could I just point out that MANY PHP functions do things like this:

/* returns int for blah blah
 * returns false in case of error
 */
function foo($x){
  if (world_has_ended()) return false;
}

So if you're going to insist on type hints, can we not at least make
it sensible and have syntax like:

int|bool function foo (){
}

So foo() returns int or bool.

Otherwise, you end up with (int) false strewn all through your code,
and it looks all messy.

There's a REASON why I'm writing PHP and not C, folks... :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

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

Reply via email to