Re: RFC: Functional Interfaces
| From: | Rowan Collins | Date: | Mon, 18 Apr 2016 11:34:31 +0000 |
| Subject: | Re: RFC: Functional Interfaces | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-92407@lists.php.net to get a copy of this message | ||
Joe Watkins wrote on 18/04/2016 11:22:
This sounds like a really nice feature. As well as using functions to implement existing interfaces, it gives a nice way of typehinting the requirements of a callback without forcing users to create an object. I must admit to being a bit confused by the term "functional interface" at first, though, because "functional" has so many different meanings - is this a term used elsewhere, or is it up for debate? In particular, the error message "Fatal error: cannot implement non functional interface IFoo" makes me wonder what's "non-functional" about the interface. It would be clearer to me if it was more specific and avoided the jargon, e.g. "Anonymous function cannot implement interface with more than one method". The error "functional interface cannot implement self" also seems inconsistent with the others - here "functional interface" refers to the *implementation*, not the interface. It might be clearer to just say "cannot implement non interface self" anyway - there's nothing actually special about "self" here, it's just another example of trying to use a class as an interface, which is illegal whatever the implementation. These are of course minor details, and the rest of the feature as described sounds great. :) Regards, -- Rowan Collins [IMSoP]Please review the following RFC:https://wiki.php.net/rfc/functional-interfacesAn implementation is provided, and is testable on 3v4l.