Morning, > 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?
The terminology is borrowed, Java 8 uses lamdas to implement specially annotated interfaces, it refers to them as functional interfaces. The other term is SAM ... but it feels a bit strange to give code a people name, right ? :) Single Abstract Method Interface Implementations is just ... too much ... I find it to be a pretty concise description, although the wording of the errors is definitely flexible. The "non thing" wording was only chosen because it's used elsewhere in the core, "non static" and so on. It just feels a bit strange to say or think "functional interface", but once you get over that ... As far as anyone who is not familiar with the workings of PHP is concerned, what they have is a function that implements an interface, functional interface is a pretty good description of that. Cheers Joe On Mon, Apr 18, 2016 at 12:34 PM, Rowan Collins <rowan.coll...@gmail.com> wrote: > Joe Watkins wrote on 18/04/2016 11:22: > >> Please review the following RFC: >> >> https://wiki.php.net/rfc/functional-interfaces >> >> An implementation is provided, and is testable on 3v4l. >> > > 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] > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >