On 12/29/2017 4:37 PM, Nikita Popov wrote: > int|float is the natural type of numeric operations in PHP. Integers > automatically overflow into floating point numbers, so signatures using int > in conjunction with numeric operations are somewhat problematic. > > Having an explicit number type also goes well with an explicit number cast. > PHP internally has a notion of a number cast (which is the basis for > arithmetic operations), but currently does not expose it. As such, number > casts currently have to be simulated using workarounds like +$x. >
Not sure I fully understand what you are saying. I mean, the accuracy problem will prevail no matter what because at some point we have to change that long to a double. The earlier the better so users know what they are dealing with. `+$x` seems like something that is only of interest if my source is a string and I don't know if it should be int or float. This on the other hand sounds like something that is happening at the edges of the application. Or maybe you had something else in mind? On 12/29/2017 4:37 PM, Nikita Popov wrote: > Regarding the union type RFCs, from what I remember, one of my personal > issues with it were the complex rules involving scalar type unions in weak > typing mode. It's non-trivial to decide what a value should be casted to if > it does not have the correct type. It's sort of clear what "1.5" passed to > an int|float union becomes, but it's not intuitively obvious what should > happen if you pass "foo" to a bool|int union, etc. > Why exactly is it necessary to support weak mode together with unions and intersections? It is obviously unclear in many situations what should happen, so why not simply bail like in strict mode? I mean, strict mode was added for backwards compatibility reasons. This is a new future, there is no backwards compatibility. Anyone using it shall abide to the strict rules of it. -- Richard "Fleshgrinder" Fussenegger -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php