> It seems this RFC is actually trying to accomplish two(2) things:
> 
> 1. Add typehints for nullable intersection types to PHP.
> 2. Get PHP to support a preferred syntax for type-hinting nullable 
> intersection types.

Yes of course. You cannot really do #1 without #2. 

I agree with Nicolas that `?X&Y` makes more sense. You add ? before the type. 
If the type is scalar, a class or an intersection type should not matter. But I 
hear some technical arguments from Derick so I won’t argue against that. 

Im fine with the syntax: `X & Y | null`
I don’t think parentheses should be required. From a mathematical perspective 
you want to add parentheses when you want to override the operation order. If 
you remove the parentheses and the expression has the same order of operations, 
then the parentheses is clearly not needed. 

@Larry makes an argument to keep them: 

> Requiring parenthesis now leaves the option open in the future to make them 
> optional when doing full mixed types.


I don’t understand why we should require something that is not needed simply 
because it would give us an option to remove it later… Could you elaborate why 
this is important? (Im probably missing something)

> Given both of these sets of assertions I would ask the RFC's author and 
> proponents what would be a worse outcome?

I don’t see how this question is relevant. We are not seeking compromises at 
the moment. We are seeking the best technical solution to a technical issue. 

> Also, the entire discussion has claimed a "need" for nullable intersection 
> types but AFAIIK they have been presented in completely abstract terms; i.e. 
> no one has presented any real-world scenarios where they would actually use 
> nullable intersection types.  


The “need” is covered by the discussion about PHP 7.0. See this post as an 
example: https://externals.io/message/115554#115563 
<https://externals.io/message/115554#115563>

——————

When reading my message above could make it sound like I am pessimistic. That 
is not true. I am excited about this change and I am happy PHP has a long 
feature freeze so issues like this can show up before the release. 

Regards,
Tobias


> On 23 Jul 2021, at 20:53, Mike Schinkel <m...@newclarity.net> wrote:
> 
>> On Jul 23, 2021, at 5:58 AM, Nicolas Grekas <nicolas.gre...@gmail.com> wrote:
>> 
>> Hi everyone,
>> 
>> as proposed by Nikita and Joe, I'm submitting this late RFC for your
>> consideration for inclusion in PHP 8.1. Intersection types as currently
>> accepted are not nullable. This RFC proposes to make them so.
>> 
>> I wrote everything down about the reasons why here:
>> https://wiki.php.net/rfc/nullable_intersection_types
>> 
>> Please have a look and let me know what you think.
>> 
>> Have a nice read,
>> 
>> Nicolas
> 
> It seems this RFC is actually trying to accomplish two(2) things:
> 
> 1. Add typehints for nullable intersection types to PHP.
> 2. Get PHP to support a preferred syntax for type-hinting nullable 
> intersection types.
> 
> Further:
> 
> A. There seems to be consensus on the value of #1.
> B. There seems to be consensus on using a syntax with parentheses for #1. 
> C. There is a lot of pushback on #2.
> D. The desired syntax in #2 would reduce future flexibility, as Larry 
> Garfield commented. 
> 
> Given both of these sets of assertions I would ask the RFC's author and 
> proponents what would be a worse outcome?
> 
> X. Getting typehints for nullable intersection types added to PHP, but not 
> the desired syntax?
> Y. Not getting typehints for nullable intersection types added to PHP? 
> 
> When answering please consider that #X is the outcome that would not preclude 
> possibly getting #2 at a future date.
> 
> ---------
> 
> Also, the entire discussion has claimed a "need" for nullable intersection 
> types but AFAIIK they have been presented in completely abstract terms; i.e. 
> no one has presented any real-world scenarios where they would actually use 
> nullable intersection types.  
> 
> It might be helpful — or at least it would be for me — if the RFC could add 
> two or three real-world example use-cases where the author and proponents 
> would actually like to use nullable intersection types in their future PHP 
> code.  
> 
> #jmtcw
> 
> -Mike

Reply via email to