On 29/01/12 09:51, Platonides wrote:
Doesn't seem to have arrived into the list. Resending.
On 27/01/12 16:17, Platonides wrote:
- Is there a simple Lua syntax guide?
http://www.lua.org/manual/5.2/ looks more like a grammar. Certainly not suitable for end users.
Yes, the first edition of Programming in Lua is available online:
http://www.lua.org/pil/
The reference manual is under a free license, so I imagine we would fork it on mediawiki.org, incorporating changes for standard library functions that are changed or removed, and documenting any MediaWiki-specific libraries.
- The decision seems to have been Lua vs JS. What discarded a
custom language? (such as WikiScripts)
Mostly performance.
- How hard is it to translate Lua to PHP?
(for templates which then get converted into extensions)
I don't know why you would want to do that, but I imagine it would be no harder than converting between any other pair of weakly typed procedural languages.
Server side Lua scripts could potentially execute much faster than Zend PHP, so we might start wondering how hard it would be to convert the other way.
- Where would code live?
In a "scripts" namespace.
- I think it _would_ be possible to make an extension defined with
<wikiscript> to take over the page. (avoiding the need of template wrappers)
I'm not sure what you mean by that.
- What's the expected way of implementing 'libraries' in the wiki?
I think it would be best to follow the Lua conventions here:
http://www.lua.org/pil/15.html http://www.lua.org/manual/5.2/manual.html#6.3
Basically, a Lua package is a script which returns a table of functions. There are a number ways to do this, such as:
local P;
function P.foo() ... end
return P;
A require() function would return the table. Initially require() would only fetch packages from the local wiki, but when interwiki transclusion is introduced, it would be expanded to allow libraries on remote wikis to be fetched. We would isolate the global namespace of packages to prevent global variable exports. So package invocation would be along the lines of:
package = require("The package title"); package.foo()
Assuming I understood him correctly, Trevor expressed a preference for having a function that returns a function value which returns a table when called, instead of just returning the table directly. For example:
packageFunction = getScript("The package title") package = packageFunction() package.foo()
We could have that interface as well, if there's an application for it. For consistency with the Lua reference manual, I don't think this interface should be called require().
-- Tim Starling