merged branch fabpot/callables-everywhere (PR #905)
This PR was merged into the master branch.
Commits
-------
1918ede added the ability to use any PHP callable to define filters, functions, and tests
Discussion
----------
added the ability to use any PHP callable to define filters, functions, and tests
Everything is in the title.
---------------------------------------------------------------------------
by Tobion at 2012-11-18T13:25:51Z
Are filters etc. slower when defined as closures (instead of function definitions)?
---------------------------------------------------------------------------
by fabpot at 2012-11-18T13:30:47Z
@Tobion No, it does not matter how they are defined. Speed will be the same. A function is probably slightly faster as we can optimize the compiled template more than when it is an anonymous function where we need to use `call_user_func`.
---------------------------------------------------------------------------
by Tobion at 2012-11-18T13:40:17Z
This slight difference is what I questioned. On top of that, PHP can also not precompile those `call_user_func` I guess (e.g. when using APC). But it's probably not a big deal.
Since you have many examples in the doc with closures, I hope that it does not become the standard way for people to define custom functions.