3 ms·
One nitpick from the article, PHP does have first class support for functions in the language. Functions are available in a few different ways: - Normal functi
by yurishimo 3y ago
One nitpick from the article, PHP does have first class support for functions in the language. Functions are available in a few different ways:
- Normal function declaration in global and "module"/namespace scope.
- Anonymous functions that can also be assigned to variables (except in a few cases, like object properties)
- Anything extending the Closure class
The last one is obviously a nod at what is going on under the hood, but as far as the developer writing the code is concerned, it doesn't matter.
A library even exists to explicitly provide some functional programming functions under a namespace for easy inclusion with other projects. There is no requirement that all functions must be defined in a namespace, as evidenced by the first 10 years of crappy PHP code littered with functions in the global namespace!
https://github.com/lstrojny/functional-php https://github.com/lstrojny/functional-php
Edit: formatting
- colanderman 3y agoSo does C++ for that matter. `std::function` has existed since C++11 (which does predate the essay).