> Not much else to say, the syntax reads a bit weird/heavy being all in-line
> with the function signature but at the same time I can't imagine how else it
> would work that would be any better.
As mentioned on Reddit and in the future scope section of union types,
we may want to introduce named type expressions:
type IntReducer = callable(int, int): int;
Which would also allow unions (if passed, of course):
type Iterable = Array | Traversable;
It would also allow for a general type-aliasing mechanism for single
names. This feature has been asked for in the past but I can't
remember the use-cases so this example is not very good:
type Foo = SomeFoo;
Then we just use the names where we would have put the expressions:
function reduce(int $a, int $b, IntReducer $reducer): int {
return $reducer($a, $b);
}
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php