Re: [RFC] [DISCUSSION] Scalar Pseudo-type

From: Date: Fri, 29 Dec 2017 14:20:14 +0000
Subject: Re: [RFC] [DISCUSSION] Scalar Pseudo-type
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-101437@lists.php.net to get a copy of this message
> On 29 Dec 2017, at 19:56, Fleshgrinder <php@fleshgrinder.com> wrote: > >> On 12/29/2017 1:26 PM, Rowan Collins wrote: >> On 29 December 2017 12:08:16 GMT+00:00, 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 >>> int and since >>> int is already automatically changed to a >>> float, well, you're >>> done. >> >> I think it is somewhat tedious if we discuss every possible pair of >> types, just as it would be somewhat messy if we added a new keyword >> for every combination we found a use case for. The beauty of a >> general-purpose syntax is precisely that a user can use whatever >> combination they need, and not use combinations they don't need. I'm >> sure there are plenty of nonsensical or redundant checks that can be >> expressed in other parts of the language, but that doesn't mean those >> language constructs are useless or damaging. >> >> Regards, >> > > I agree and I do not intend to do so, I actually am not even questioning > the usefulness of union and intersection types. I am more curious in > regards to providing a number type. Seems useless to me. > > -- > Richard "Fleshgrinder" Fussenegger > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > I'm not sure "number" as a predefined type union is necessary but int|float would allow a method to accept either in strict mode, and as you said it would also be useful for eg a formatting function.

« previous php.internals (#101437) next »