> On Feb 7, 2015, at 7:52 PM, Rasmus Lerdorf <ras...@lerdorf.com> wrote:
> 
> On 02/07/2015 09:51 PM, Andrea Faulds wrote:
>>> tan(1);
>>> echo strstr("test", "est", 1);
>> 
>> Banning int->float and float->int is both a pain point and sometimes a 
>> life-saver. It’s annoying that tan(1) doesn’t work. On the other hand, you 
>> discover if your ints floats would be silently truncated (as I did with 
>> PictoSwap).
>> 
>> I wouldn’t say that int->string not working is a problem, though. Seeing 
>> something like strstr(“test”, “est”, 1); is rather confusing. Looking at it, 
>> I’d think the third parameter is some sort of number for you to want to pass 
>> an integer to it. If I want a string, I’ll use one.
> 
> This isn't int->string. This is int->boolean. The 3rd arg to strstr() is
> a boolean and passing 1 instead of true makes it blow up. It is very
> very common for people to pass 0 or 1 in place of true/false to all
> sorts of things in PHP.


Thanks for those relevant examples.
I think it’s also worth emphasizing that in C people frequently work around 
this by forcing casts. The value of strict typing diminishes quickly and the 
code ends up being less readable.

I think in PHP this is going to be even more so due to the reasons Rasmus 
states. We have *a lot* of places like this which will lead to unnatural acts 
and code which is no more strict than it was before (just not as pretty).

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

Reply via email to