Talk:Lua scripting

script call template ?
18:57, 2 April 2012 (UTC), Rical wrote:

Sory if my edit is not in a right place. The question is about the transition between template and lua. There are lots of templates and js scripts and they will not disapear. Is it a good idea to permit to call them from lua scripts ?

I well understand this is a very bad way because the time and ram uses. But this permit to re-use a large number of existing template, waiting the time when they will be replaced by lua scripts.

Bots could replace template calls with lua script calls each time a replacement is OK.

-- Rical (talk) 21:11, 2 April 2012 (UTC)


 * I'm not sure at the moment whether invoking templates from Lua should be included in the initial deployment, since it's complex from the perspective of security and resource limiting. A simpler feature to implement would be allowing Lua functions to return some unexpanded wikitext for the parser to later expand. Do you think that would be useful? -- Tim Starling (talk) 00:28, 10 April 2012 (UTC)


 * Yes, this is an other way for same goal.
 * A template call a Lua fonction with parameters
 * Then the Lua fonction generate an unexpanded wikitext, including adapted template call with adapted parameters
 * The unexpanded wikitext can include one or some template calls.
 * Then the parser expand wikitext including the template call(s).
 * I think this is simple to code in parser and in Lua users-scripts and this re-use existing template and would be usefull.
 * But ...
 * If we hope to replace existing template by more efficient Lua script, this way do not permit to easy replace the calls of them. The next step should be :
 * A common extra fonction could be defined in Lua library to do the same as before. Exemple :
 * s = templateCall( s, templateName, param1, param2, ... )
 * Then replace the template call by a future Lua equivalent script become 'easy', even by bot. The replacement give :
 * s = equivalentLua( s, param1, param2, ... )
 * Is this a right way ? Do we want replace many templates ? Will we be able to translate-convert many tempates by equivalent Lua scripts automatically ?
 * Rical (talk) 17:02, 10 April 2012 (UTC)

var in template

 * Some time in template i would like to use var that could replace repeated code. This could reduce the interpreting time, simplify and reduce the code.
 * To do it we could use negative parameters and a syntax similar to switch.
 * To define and  we could code :
 * Rical (talk) 23:34, 3 April 2012 (UTC)
 * Rical (talk) 23:34, 3 April 2012 (UTC)


 * No, there won't be any feature which requires wikitext to be parsed in a certain order, such as top to bottom. This gives us some more flexibility in future parser design. Memorization is probably the best option for efficiency. -- Tim Starling (talk) 00:28, 10 April 2012 (UTC)


 * Yes, '#var:' was not the right word, my idea was to memorize a wikitext value in  as local constant to re-use it in the next wikitext in the same template at the same level. The parser extented function could be #const: or #constant:
 * Rical (talk) 17:02, 10 April 2012 (UTC)
 * Rical (talk) 17:02, 10 April 2012 (UTC)


 * After a few minutes, i think that the value of a «constant» could be replaced by an other value to generate the next wikitext later in the same template. Then the «constant» becomes almost a variable on the same local level. The parser is not more complex. Rical (talk) 21:26, 10 April 2012 (UTC)

Simple users
How will any simple wikiuser without a programmer's background learn to use this? Now it seems to me that only those who learnt programming will be able to use it. Now even the simplest templates can make some editors cringe, how is this going to work in everyday wikilife? I just can't imagine trying to tell new users to learn scripting in Lua to make templates... Or will this have a user friendly interface? Teemeah (talk) 13:20, 2 June 2012 (UTC)
 * I think the simple answer is that nobody expects new users to do this. Templates can already be quite complicated, juggling all the  and   and  . And if people want to use the “old” template syntax, they still can. Also, it's pretty much impossible to make something that is both powerful and “user friendly” so that new users without any programming background could quickly pick it up. Of course, a dedicated newcomer should be able to pick it up, but Lua is probably one of the better languages for this, because it's quite simple. Svick (talk) 13:32, 2 June 2012 (UTC)

Breaking the server
Can I try to break the server with this, or is that discouraged? --Carnildo (talk) 23:15, 22 August 2012 (UTC)

Unicode support
Is there any plan to make Lua function properly with unicode characters? At the moment, string length seems to be being measured by how many bytes are in a string, not how many proper characters. Having string manipulation work with non-ASCII characters would be necessary if this is to be deployed on non-English wikis, I think. --Yair rand (talk) 03:13, 23 August 2012 (UTC)

Errors


Error handling is terrible. What are we supposed to do when faced with error messages like that? This, that and the other (talk) 11:15, 23 August 2012 (UTC)
 * Oh, I see... it's an HTML comment. Still, that is rather abstruse. This, that and the other (talk) 11:15, 23 August 2012 (UTC)
 * It looks like you can click on the error message and it will show a small window with the error message. But that's still really confusing, I wouldn't expect big red error message to be clickable or that clicking will show the error in that window. Svick (talk) 13:27, 23 August 2012 (UTC)
 * Tim Starling tried to help about this. You can read his answer there :
 * « I wrote a debug console module and deployed it here, let me know what you think of it. » -- Tim Starling (talk) 04:50, 14 July 2012 (UTC)
 * You could try it and return your feeling to him and us. --Rical (talk) 19:51, 23 August 2012 (UTC)

API/syntax
Lua fellow here. The syntax and API described in Lua_scripting/Tutorial could IMO be improved. I hope it is not too late...

Regarding the API, why do you pass the arguements in the frame table? I don't know the purpose of the frame, but I suppose that it contains meta-information. With the current system, reading an argument requires two table lookups, which are far more expensive than fetching an argument (similar to a local lookup). Furthermore, you create the  table, which takes time, space, and time again when the grabage collectore runs. I'd suggest something like this:

function p.foo(frame, named, bar, baz) ... end

would be nil unless there are named arguments. In that case, it is a table with appropriate key/value pairs. It would be up to the Lua scripter to handle both named and unnamed arguments if they occur. Alternatively, named arguments could be part of the frame, but only when they exist.

if frame.named then bar, baz -- already locals since they are arguments = frame.bar or bar , frame.baz or baz end

Actually, I'm not sure if the positional args should be preserved when named arguments are used. It would probably be confusing for editors. Either go all positional or all named (but a given functions could support both).

Regarding the invocation syntax,  (or a variation thereof, I'm not familiar with the meaning of initial sigils in WikiMedia templates) is ligther, more readable and more semantic than. It also allows to have modules that are actually just one function. -- Pierre-Yves 89.90.144.90 15:08, 30 August 2012 (UTC)
 * Hi, Pierre-Yves. Thanks for your note. Tim Starling discussed it starting around 01:12:10 in these IRC logs. Hope this is helpful. Sumana Harihareswara, Engineering Community Manager (talk) 01:40, 6 September 2012 (UTC)