Search results
Results from the WOW.Com Content Network
Function names are often of the form p.myFunctionName, where p is the table from the return p at the bottom of your program. The reason for this is that you can only access functions that are entries in this table from the original #invoke statement. Functions for local use within the program can have any name.
Marshalling data between C and Lua functions is also done using the stack. To call a Lua function, arguments are pushed onto the stack, and then the lua_call is used to call the actual function. When writing a C function to be directly called from Lua, the arguments are read from the stack. Here is an example of calling a Lua function from C:
function p. q is syntactic sugar for p ["q"] = function. function builds a function. It doesn't declare it. Functions are first-class objects and can be assigned to variables, placed in tables, serialized into strings, and deserialized back out again. Think interpreted, not compiled.
Wikipedia:Lua string functions – string performance considerations and limits; Wikipedia:Guide to Scribbling – how to write templates that use Scribunto/Lua; Wikipedia:Guide to Scribbling/Programmers' Quick start Guide to Lua – a list of essential points; Wikipedia:Comparable Lua functions to wikitext – how to convert wikitext to Lua
Help:Lua for beginners; Help:Lua debugging – about debugging Lua modules; Wikipedia:Lua style guide – standards to improve the readability of code through consistency; Module:Sandbox provides a pseudo-namespace for experimenting with Lua modules
So, much of what these books explain about Lua standard library functions and variables that come with the language is either irrelevant or untrue here. The original API specification — the Lua standard library functions and variables that are supposed to be available in modules — is given at MW:Extension:Scribunto/API specification ...
Before creating too many variations, remember that wp:parser functions often run faster than Lua-based templates, and #switch:1 can branch by any combination of range-tests or complex multi-part conditions, as explained in Help:Switch. Recall how any branch, of a #switch, can be written as:
The string-search functions in Lua script can run extremely fast, comparing millions of characters per second. For example, a search of a 40,000-character article text, for 99 separate words (passed as 99 parameters in a template), ran within one second of Lua CPU clock time.