On Wed, May 2, 2012 at 2:28 PM, Platonides Platonides@gmail.com wrote:
Is it possible to hook Lua function calls? If so, I'd make a template expansion a "call" to a function with that name. That was the interface I envisioned when thinking how I'd do it if making the language from scratch to suit wikitext (I drafted some code, but didn't reach to a barely mature level).
Do you mean a situation when you have template X and call to function X is a transclusion of template X? I have also thought about that as well. Not all titles are legitimate Lua function names, but there are more serious issues with that.
This is close to how the first implementation of InlineScripts was done in 2009. As it turned out, this approach has numerous disadvantages, the main of which are performance issues (introducing overhauls by calling the functions through parser instead of direct call; this is actually a big problem when you have many function calls), inability to return non-string data (like arrays) and impossibility of exporting multiple functions from one template. That's why I strongly believe that all code should be in modules and modules should be interacting only through Lua itself.
—Victor