Re: [RFC] [Discussion] Rounding Integers as int
| From: | Larry Garfield | Date: | Sat, 09 Mar 2024 16:00:21 +0000 |
| Subject: | Re: [RFC] [Discussion] Rounding Integers as int | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-122594@lists.php.net to get a copy of this message | ||
On Sat, Mar 9, 2024, at 1:01 AM, Marc wrote:
> Hi internals,
>
> Just want to resent this note about the updated RFC as there where no
> comments last time and I'm unsure if this was due to mailing list issues.
>
> I now have updated the RFC to allow to opt-in to new behavior on PHP 8.4
> and be able to opt-out to previous behavior in PHP 9.0 via new parameter
> "force_float".
>
> Also the deprecation has been removed as nobody liked it.
>
> If no further comments arrive I'll like to start voting next week Friday.
>
> Best regards,
> Marc
I am still opposed to this. Logically, ceil/float/round should be returning ints, not floats. Only
returning ints if it was given an int is, er, kinda pointless, as you'll just get back the
value you passed in. (Because it's already rounded/floored, etc.) So this doesn't get us
any new type safety, but does make the return type less consistent than it is today. That's a
step backwards.
If there's some math reason that we cannot have those functions return int (someone mentioned
there was, but I don't really understand it and the RFC does not explain it at all), then we
should at least keep consistency in the return type. "Sometimes I have to cast the return
value before I can actually use it in the obvious way, sometimes I don't" is not a good
situation.
--Larry Garfield