Re: Re: Improving PHP's type system
| From: | Lin Yo-An | Date: | Sat, 16 Apr 2016 01:12: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 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-92359@lists.php.net to get a copy of this message | ||
If we can pre-define the types via something like this:
data Tree a = Branch (Tree a) (Tree a) | Leaf a
And only allow one type for each function parameter in the prototype, then,
I think the performance impact of type checking in the runtime can be
reduced.
In other words, you predefine the union type before you used them, and the
union types can be reused in different functions, you don't write a lot
union type in function prototype.
For example,
typedef T = array | Traversable
function foo(T $a) { }
function bar(T $b) { }