Re: Nullable types before union types
| From: | Björn Larsson | Date: | Mon, 29 Aug 2016 14:21:33 +0000 |
| Subject: | Re: Nullable types before union types | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-95504@lists.php.net to get a copy of this message | ||
I think you will find information about this in the threads
for discussion and voting regarding Nullable types RFC:
- https://marc.info/?l=php-internals&m=146060540111128
- https://marc.info/?l=php-internals&m=146289381815830
- https://wiki.php.net/rfc/nullable_types
Regards //Björn Larsson
Den 2016-08-29 kl. 15:36, skrev Igor Inas:
Hello, same as last post in the mailing list - this may have been suggested before - but I had hard time finding it in the archives. Coming from static typed languages, I love the addition of return type annotations and extension of parameter type annotations. I also love the fact, that types are not nullable by default. I am reading about the proposal to add nullable types before union types are fully implemented. This would be done by utilizing question mark (int? / ?int). My question is: would it be too difficult to implement nullable types using syntax of union types, but semantically, only max two types would be allowed in the union and one of them would have to be null. So only allowed forms would be: - int | null - null | int I am thinking about the future, when union types become implemented and suddenly there would be two ways how to annotate the same nullable type: - int | null - int? Thanks for more insights, Regards, Igor