Re: Re: Improving PHP's type system
| From: | Zeev Suraski | Date: | Wed, 20 Apr 2016 12:55:19 +0000 |
| Subject: | Re: Re: Improving PHP's type system | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-92539@lists.php.net to get a copy of this message | ||
On 20 ????? 2016, at 14:54, Jesse Schalken <me@jesseschalken.com<mailto:me@jesseschalken.com>> wrote:
If I had "scalar", "number" and ?T as types, the types I would need would be:
1. ?scalar|Decimal
What's decimal? I'm not aware we have that type. Apologies if I missed it that it was
added.
1. ?scalar|Decimal|Expr
What's Expr? Again I'm not aware that we have that type.
In both, a nullable scalar does the job.
1. ?scalar|array
Conduct this check in user code, you'd have to anyway.
1. int|string (I want int|string here. I know array keys are always int|string. A wider type is
lies.)
This is needlessly purist. For handling a meaningless con, we'd overcomplicate the language
and provide a footgun(tm) for everyone. Not a good bargain.
1. ?scalar (probably)
Ok
1. number
Ok
1. T|false
You didn't answer my question on this one.
1. ?T
Ok
5 out of 8 still need a union.
Actually, in my count only one of them does (#7) and it's probably solvable (if it's even
a thing), and in another, it makes no sense to use types at all (#3) as you'd have to do these
checks in userland anyway. All others can be satisfied just fine with scalar, numeric and nullable
types, unless you're being needlessly purist - and we're not going to overcomplicate the
language for the sake of purism.
Zeev