Extension talk:WikiScripts

It would be so nice if extension authors would put up a summary that told us something more than the title of the extension, and if they would take the time to put an actual example in place.

Keywords in and contains.
These are important and I think you should add definitions and maybe examples. Also, is there a way to remove a key/value pair from an array?

--AJim 22:10, 17 August 2011 (UTC)
 * Yes, delete( a['key'] ). I'll add that. VasilievVV 22:11, 17 August 2011 (UTC)

numeric functions
I think there have to be at least a few numeric functions defined. Perhaps floor, ceil, round, sign, abs at least. If the underlying language supports them then also log, exp, sqrt maybe max and min maybe rand and maybe even trig? Or do we just assume that if they are in js then they are here? --AJim 22:56, 17 August 2011 (UTC)
 * Coming soon. VasilievVV 15:46, 18 August 2011 (UTC)

date/time datatype and functions
I think there will be a need for date/time operations and I think it would be a mistake not to have them well-defined, paricularly in light of how much pain they have caused me in the past. --AJim 22:55, 17 August 2011 (UTC)
 * I will add datetime type when the date/time functions are added. This is not high priority issue however, so I will probably focus on that later. VasilievVV 15:46, 18 August 2011 (UTC)

short-circuit evaluation
I assume that logical evaluation (& |) short circuits, but it would be nice if the description said so. --AJim 22:59, 17 August 2011 (UTC)

escaping a for construct
Is there a way to terminate a for evaluation if the program discovers that it should not go on? --AJim 23:07, 17 August 2011 (UTC)
 * Added break/continue into documentation. VasilievVV 15:46, 18 August 2011 (UTC)

Named parameters
One thing I like about MediaWiki templates relative to real programming languages is that you can use named parameters very easily, and therefore that you don't have a fixed order of the parameters. It looks to me like it will be a pain to implement something like Cite web fully in the current version of this extension, because you really need the flexibility of named parameters. I suppose this problem could be solved by making Template:Cite web into a wrapper that calls Module:Cite web with all the parameters in the right order, but that's ugly. Ucucha 00:45, 18 August 2011 (UTC)
 * Well, as for templates, if you #invoke a function from template, the function (as well as all the other functions it calls) have access to the parser frame of the template, i.e. to all the arguments in it. See "Template library" in "Built-in functions". VasilievVV 15:46, 18 August 2011 (UTC)

some thoughts
hmm, I like the looks of this. Some thoughts (This is after only about half an hour of looking at it so some of these might be stupid thoughts or they might be already implemented and i just don't realize): Bawolff 03:06, 18 August 2011 (UTC)
 * more complex argument handling: It might be nice to have named arguments to functions, like you can do in C# (Ucucha also mentioned that above). It'd also be nice to be able to do variable number of arguments (Maybe an arguments array like in js, or some function to get an array of arguments)
 * I think the yield statement should maybe be named something else - It does something kind of different from what yield does in other languages. You wouldn't be able to make a generator that generates an infinite list with yield like you could in other langs. (although given we don't have loops other than looping over an assoc array, I guess you wouldn't be able to use yield in that fashion anyways even if it worked like in other langs).
 * Minor issue - it seems like it doesn't hook into update.php properly.


 * For first issue — can you propose alternative syntax? Same for the second issue. I will fix the third one today or tomorrow. VasilievVV 07:26, 18 August 2011 (UTC)


 * Possibly a separate keyword:


 * Invoked with:
 * Ucucha 12:24, 18 August 2011 (UTC)

The C# way would look something like this (I've never programmed C# so i don't know how it works in practise, but it looks cool. This is based on ) someFunc(arg1, arg2, arg3 = "3") { // do stuff

} // and all the following would be equivalent way's to call the func: // self::someFunc( 1, 2, 3); // self::someFunc( 1, 2 ); // self::someFunc( arg1: 1, arg2: 2, arg3: 3); // self::someFunc( arg2: 2, arg1: 1, arg3: 3); // self::someFunc( arg2: 2, arg1: 1); // self::someFunc( 1, arg3: 3, arg2: 2); // // In Wikitext it would be like, etc In that scheme I think it'd make sense to require that positional non-named arguments must come first if being used (so  would be illegal ) and in the function deceleration, any optional args would have to be last ( so   would be illegal)

I also think it'd be good to have an equivalent to tpl_named_args and tpl_numbered_args for the function (func_named_args or whatever) that would return the functions arguments (in order to be able to do variable number of arguments. If one specifies more arguments than the function accepts you could get the other args with func_named_args). It also might be nice to have a  to be like tpl_named_args, but also have all the numbered arguments have keys like "1", "2" etc.

Another thing that might be interesting is to have a concise syntax for making ranges. For example have  be equivalent to [1,2,3] and perhaps   be the same as. I imagine end users are going to want to emulate standard c-style for loops (although I do really like the fact this language doesn't have such loops). makes nice syntax imho.

As for the yield thing - I unfortunately can't think of a better name for it. Maybe push (because it's kind of like pushing a new value on to the stack of things to return from the function).

Cheers. Bawolff 17:14, 18 August 2011 (UTC)

understanding finished example
I think it would help to show the invocation of the module as well as the output, so that the source of the last line in the table was evident.

I also do not understand the significance of adding true to the return value of main.

--AJim 16:54, 18 August 2011 (UTC)


 * Whoops. That was the test code which I forgot to remove. VasilievVV 17:07, 18 August 2011 (UTC)