From: Fabien Potencier Date: Tue, 11 Dec 2012 11:12:31 +0000 (+0100) Subject: merged branch fabpot/callables-everywhere (PR #905) X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=b22c076fc2eee4ba641b7ec20d3f3023da290ef0;p=web%2Fkonrad%2Ftwig.git 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. --- b22c076fc2eee4ba641b7ec20d3f3023da290ef0 diff --cc CHANGELOG index 8bd3e26,0f3b7fd..3a2771e --- a/CHANGELOG +++ b/CHANGELOG @@@ -1,6 -1,6 +1,7 @@@ * 1.12.0 (2012-XX-XX) + * added the ability to use any PHP callable to define filters, functions, and tests + * added a syntax error when using a loop variable that is not defined * added the ability to set default values for macro arguments * added support for named arguments for filters, tests, and functions * moved filters/functions/tests syntax errors to the parser