Re: [RFC] Callable Types

From: Date: Fri, 22 Apr 2016 14:39:36 +0000
Subject: Re: [RFC] Callable Types
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-92642@lists.php.net to get a copy of this message
> 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); }

« previous php.internals (#92642) next »