On Jan 6, 2008 9:37 PM, Stefan Priebsch <[EMAIL PROTECTED]> wrote:
> I'm a little afraid that introducing type hints will have us end up with
> code like this (to stick with a previous example):
>
> <?php
>
> function foo(int $a) {}
>
> foo((int) '5');
>
> ?>
>
> So, just to make sure, add Java-ish typecasts everywhere. I'm not sure
> if that solves the problem (error handling still required when the cast
> is not possible), but maybe someone could comment on the performance
> implications of adding explicit typecasts in every function call?


When a method or function uses the strict typing, it is on purpose. It
is documented (self documented and hopefully using normal docs). There
is no need of error handling, it is an usage error and should raise a
E_{whatever}, be happy, it will not be fatal as it is now in all these
OO strictness (with or without good reasons :).

About performance, I doubt there is any difference. The cast is done
at some point anyway. And the function/method will not have to add
these horrible tests like is_int, is_numeric and all other related
tests.


-- 
Pierre
http://blog.thepimp.net | http://www.libgd.org

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

Reply via email to