logoalt Hacker News

jmyeet • today at 2:24 PM • 0 replies • view on HN

So there are two potential problems being addressed by this.

1. The chosen example is for PHP versions. That might just be the example but this sort of thing is a real problem. Personally I prefer something like the polyfill method as seen in Javascript where possible. Python has to deal with this too since it seems like every 3.x release now makes breaking changes. That might be just be their trivial example; or

2. Closures. Looking at the linked doc that seems to be a use case. PHP suffers here (IMHO) from having a really poor type system. Having closure arguments as question marks seems... inelegant. I'd really prefer to be able to type those and also know that the variable I have itself is a callable of some kind. I always point to the Hack type system as a comparison here.

So I dislike the name "partial function arguments" because it's unclear what the purpose is. If they're closures, call them closures. If PHP's PFA's can't bind variables (I didn't look into whether they could or not, call them something else?

The word "partial" here is really what I'm having issue with. I'm reminded of partial classes from C#, which solved a problem of creating part of a class from, say, a config file. The first example I saw was WPF using XML to define UI elements where the framework compiled the XML into partial classes and you had to fill out the rest for it to compile. I guess it's a bit like declaring a header and then failing to link an implementation (in the C/C++ world).