> De : Zeev Suraski [mailto:z...@zend.com] > > That means that "42" can coerce into int, and "42.2" can coerce into float, > and int can coerce into float - but not vice versa.
I was wondering : should we systematically reject float to int, or should we accept it when range fits and fractional part is null ? Shorter : can 7.0 be considered as an integer ? Example : if we completely disable float to int : function foo(int $arg) {} foo(ceil(<any number>)); <- fails while ceil result is always integer foo(abs(<float>)); <- the same On one side, it depends on value, which is not so good. On the other side, we must consider, the number behind the representation *is* an integer. And PHP math functions too often return integers as floats (mostly for a question of range) Anyway, one more use case against strict mode, as the examples above, while considered intuitively and technically correct, would fail. And there several more. Would the solution be to create another exception :) ? > A somewhat sticky points is coercion into boolean. We need to figure this > one out, and hopefully we can come up with something most people can > agree to. As I already said, with such a C-like syntax, we probably cannot disable (int -> bool), so the same for 'integer string' to bool, as it is natural to give this the same rule as native int. Not sure for float but I would say OK too, as C habits prevail IMO. > Another open question would be coercion of float/int into string. This > particular point might be good for a secondary vote, as I imagine people > from both camps won't see this particular conversion as a major deal-breaker > for them (could be wrong). I don't see the point here. It creates data but there's no ambiguity in the way to represent it as a string. I think bidirectional 'numeric string' <-> int/float conversion is a concept easier to understand and remember. Regards François -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php