Re: [Discussion] Callable types via Interfaces
| From: | Larry Garfield | Date: | Tue, 25 Apr 2023 21:39:41 +0000 |
| Subject: | Re: [Discussion] Callable types via Interfaces | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-120131@lists.php.net to get a copy of this message | ||
On Tue, Apr 25, 2023, at 6:20 PM, Michał Marcin Brzuchalski wrote:
> Personally I don't like this way of shaping callable types. Given examples
> are really confusing me. Call of a castTo() with argument representing an
> interface with a method is confusing as the method magically appears on a
> closure without explicit binding to it! What if an interface has more than
> one method? What if I wanna choose which one?
Multi-method interfaces would be explicitly disallowed and trigger an Error. If providing only a
single "method", then there's no logical way for it to satisfy a multi-method
interface. But there are ample single-method interfaces around PHPlandia. And a single-method
interface has no ambiguity about which method the closure corresponds to.
--Larry Garfield