Re: Reviving scalar type hints
| From: | Dmitry Stogov | Date: | Tue, 24 Feb 2015 07:15:53 +0000 |
| Subject: | Re: Reviving scalar type hints | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-83634@lists.php.net to get a copy of this message | ||
On Fri, Feb 20, 2015 at 10:48 PM, Robert Stoll <php@tutteli.ch> wrote:
> Hi Dmitry and Anthony,
>
> I was skimming through your conversation about JIT/AOT and that type hints
> would allow to optimise few things.
> I do not know if you are aware of the following but type hints can be
> passed by. Hence neither weak or strict type hints allow to predict the
> type (even if only locally):
>
> function handler($errno, $errstr, $errfile, $errline){
> return true;
> }
> set_error_handler("handler");
>
> class Foo{}
> function foo(int $x, Foo $f){
> var_dump($x, $f);
> $y = $x; //should be int as well, right?
> }
> foo(new Foo(), 1);
>
> Sure, this is something which is hopefully never ever done but anyway, a
> language needs to be able to handle all cases.
>
>
right. I know this of course. and this makes type hints useless.
> As a side notice, if the exceptions in the engine RFC is accepted, then
> this would not be a problem anymore:
> https://wiki.php.net/rfc/engine_exceptions_for_php7
>
"exceptions in the engine" are going to fix this.
Thanks. Dmitry.
>
> Personally, I would expect that the execution is stopped after the
> error_handler was called (after user was able to log etc.) - at least in
> strict mode.
>
> Cheers,
> Robert
>
>
>