Re: JIT (was RE: [PHP-DEV] Coercive Scalar Type Hints RFC)

From: Date: Mon, 23 Feb 2015 01:57:47 +0000
Subject: Re: JIT (was RE: [PHP-DEV] Coercive Scalar Type Hints RFC)
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-83528@lists.php.net to get a copy of this message
On 02/22/2015 09:15 PM, Stanislav Malyshev wrote:
We were talking about the case where the argument was even, you must have missed that part. If the argument is not even, indeed both models would produce the same error, no difference there. The only difference in your model vs. dynamic model so far is that you forced the developer to do manual (int) instead of doing much smarter coercive check on entrance of foo(). There's no performance improvement in that and there's reliability decrease.
How is coercive much smarter? Basically what coercive would do is similar to what the intval(), floatval(), etc... set of functions do with some type checking on the mix to ensure a value matches some set of rules. How casting (int) could be such dangerous thing? Lets take for example this code: echo (int) "whats cooking!"; echo intval("whats cooking"); Both statements print 0, so how is casting unsafe???

« previous php.internals (#83528) next »