On Tue, Mar 23, 2021, at 4:32 AM, G. P. B. wrote:
> Greetings internals,
> 
> I'm presenting a new RFC to add support for pure intersection types to PHP.
> 
> An intersection type A&B means that the value must be of type A and of type
> B at the same time.
> 
> I'm calling this proposal pure intersection types as there would be no
> possibility of mixing intersection and union types, I'm leaving this as a
> future scope.
> 
> The current draft is located on GitHub:
> https://github.com/Girgias/intersection-types
> And the current implementation PR is:
> https://github.com/php/php-src/pull/6799
> 
> Looking forward to the feedback.
> 
> Best regards,
> 
> George P. Banyard


I love this!  Thanks, George!

A few editorial notes:

* Under "Duplicate and redundant types", the prose says "For example, if ''A'' 
and ''B'' are class aliases, then ''A&B'' remains a legal intersection type".  
The code sample after it, however, says it's an error.  Please clarify.

* Under "Adding and removing intersection types", there appears to be some 
broken code formatting.

* The Reflection section still refers to "union" types.  I assume that's 
because that section is still a WIP.

* Under "Future Scope / Type Aliases", you refer to "number" as being an alias, 
but the code sample calls it "CountableIterator".

Design notes:

* Should we be planning ahead for some future where union and intersection 
types can be mixed and design the reflection API accordingly?  I worry that if 
we have a ReflectionIntersectionType, and a ReflectionUnionType, that 
ReflectionIntersectionAndUnionType is just going to make both implementers and 
users table-flip.

--Larry Garfield

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to