Re: [RFC] Union Types v2
| From: | Björn Larsson | Date: | Mon, 30 Sep 2019 10:18:12 +0000 |
| Subject: | Re: [RFC] Union Types v2 | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-107351@lists.php.net to get a copy of this message | ||
Den 2019-09-26 kl. 10:06, skrev Nikita Popov:
On Tue, Sep 24, 2019 at 10:06 PM Sara Golemon <pollita@php.net> wrote:Hi Nikita, Given the feedback on 23/9 from B Morel regarding occurrence of true as a return value, would you then consider adding true as a valid return type in unions? r//Björn LOn Tue, Sep 24, 2019 at 12:24 PM Claude Pache <claude.pache@gmail.com> wrote:This RFC is currently held up by a lack of implementation. Once that is done, the RFC will go forward as-is (barring any novel concerns). Because I consider it an important part of the overall proposal (*), I will neither remove the false type, nor split it into a separate vote. People may vote against the whole RFC if they disagree with this aspect, or any other aspect of the proposal. Regards, Nikita (*) While certainly not the primary reason for why we should support union types, the reason why I brought this proposal forward at this time specifically, is that the lack of union types is a blocker for my pet project of providing comprehensive type annotations for internal functions. Supporting "false" is strictly necessary for this purpose, because it is part of nearly all unions as far as internal functions are concerned.The choice of supporting precisely the two literal valuesnullandfalseis not arbitrary: They are the two values that are the most often used as sentinel values (for indicating failure or absence). It is true thattrueisalso sometimes used as sentinel value (more rarely and not among the internal functions), but the same can be said of other literal values (one of your examples includesWhile I personally think0).falsemakes sense as an allowed "type", I also don't want to see the union types RFC get held up on such a tiny detail. I would propose either of the following alternatives: 1/ Removefalsefrom the proposal. It can always be added at a later time, but not taken away. 2/ Make this detail a sub-vote. I would suggest that this sub-vote should also be subject to a 2/3 majority in order to pass. -Sara