Re: [RFC] [Discussion] Literal Scalar Types
| From: | Tim Düsterhus | Date: | Mon, 15 Jun 2026 20:32:53 +0000 |
| Subject: | Re: [RFC] [Discussion] Literal Scalar Types | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-131303@lists.php.net to get a copy of this message | ||
Hi
On 6/15/26 21:45, Seifeddine Gmati wrote:
For what it is worth, I am personally fine withYes, it is consistent with the existing behavior, but I don't think that this makes it any less confusing. And for this specific proposal, adding support for floats would be a deliberate decision rather than just something that naturally follows from “existing === semantics” as withtenths(0.1 + 0.2)failing to match0.3. This is not new behaviour:0.1 + 0.2 == 0.3is already false, and amatch (0.1 + 0.2)already skips a0.3arm for exactly the same reason. So a literal float type behaves consistently with comparison andmatch, rather than introducing a new surprise.
match() which works on two values rather than values + types.
On your concrete questions:Yes, I'm aware (based on a look at the implementation). This was intended to be a subtle note that this is not explicitly spelled out in the RFC. The RFC text should comprehensively explain the behavior all possible edge cases and ambiguities so that folks can form an educated opinion based on the RFC text alone without needing to be able to understand the implementation. Writing that out, I also notice that the “Ecosystem” sub-section is missing from the “RFC Impact” section (and the “To Existing Extensions ” sub-subsection would probably also be useful to know) and the voting widget is also missing. Best regards Tim Düsterhus4e3is a valid float literal and works today; it normalizes to4000.0(the type also stringifies as4000.0).NANandINF, on the other hand, are not literals but constant identifiers that go through constant resolution. They are out of scope for the same reasonFOOis above:NAN $foocould just as well mean a class namedNAN.