Re: intersection types and null for defaults, properties and return types
| From: | Niklas Keller | Date: | Tue, 20 Jul 2021 18:35:26 +0000 |
| Subject: | Re: intersection types and null for defaults, properties and return types | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-115537@lists.php.net to get a copy of this message | ||
>
> > > > nicolas-grekas wrote on the PR:
> > > > > ?X&Y cannot be confused with
> > > >
> > > > It confused me. A compiler might understand it, but as a human I have
> > > > trouble understanding it.
>
I think ?X&Y would be a pretty poor syntax choice, as it's ambiguous as
many others said: (X|null)&(Y) vs. (X&Y)|null.
What hasn't been proposed, yet, is ?X&?Y, so requiring either all or none
of the types being nullable.
Best,
Niklas