Re: [RFC] [DISCUSSION] Scalar Pseudo-type
| From: | Christoph M. Becker | Date: | Sat, 30 Dec 2017 15:13:55 +0000 |
| Subject: | Re: [RFC] [DISCUSSION] Scalar Pseudo-type | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-101455@lists.php.net to get a copy of this message | ||
On 29.12.2017 at 16:37, Nikita Popov wrote:
> On Fri, Dec 29, 2017 at 1:08 PM, Fleshgrinder <php@fleshgrinder.com> wrote:
>
>> What is the use case for
int|float? I mean, if f is able to
>> process a
>> float than f is able to process an gà
>> ù&]Ýh/"ÀÒÚͪint and since int is already
>> automatically changed to a float, well, you're done.
>
> 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.
In my humble opinion, introducing int|float or number types would
not solve the real problem, namely that overflowing to float easily
causes unexpected behavior. For instance:
PHP_INT_MAX + 1 > PHP_INT_MAX // => false (64bit arch)
--
Christoph M. Becker