---- Daniel Friesen dan_the_man@telus.net schrijft:
Also, a big one. I'm thinking of actually allowing mathematical variables. These can show up in the formula, and the following parameters are var=value pairs. An example of such: {{#expr:d + v×t + ½×a×t²|d=4e2|v=2|a=4|t=7}} That kind of feature would be quite nice on perhaps... A physics wiki, where you use a lot of formula that repeat variables.
Why not just create a Template:Accmotion that contains
{{#expr:{{{d}}} + {{{v}}}*{{{t}}} + 0.5*{{{a}}}*{{{t}}}^2}}
and call
{{accmotion|d=4e2|v=2|a=4|t=7}}
Does that work? Are template parameters expanded before ParserFunctions?
Roan Kattouw (Catrope)
Yes, it would work. But remember my goals with the extension. * Making complex templates more understandable (a number of more specific and useful parserfunctions to avoid the use of hard to understand parser hacks) * Making complex templates more human readable (allow unicode characters, and find lighter more readable syntaxes) * Making complex templates lighter weight on the servers (create functions like #anyexist/#findexist that reduce the queries made for things like multiple #ifexist's)
That template's formula isn't as readable when you have all those {}'s around the variables. It's also nicer to have the formula on the same page when you're doing an article on a formula. The errors you can also get out of an #expr with integrated variable handling are also more helpful. They can actually identify to you 'the formula needs the variable x, but a value has not been provided'. In classic #expr using a {{{template variable}}} you get a generic unspecific error.
Actually, along with the notion of the extension goals. You'll probably notice that I have loop functions, but there is an absense of the classic type of loop, the #while. That's something in-line with the goal. #while is something core to programming and is a bit more complex to understand. However, looping itself is useful inside of a template: {{#forN:#|{{#ifexpr:{{#}} != 1|, <nowiki/>}}{{{ {{#}} }}}}} Ok, though I admit. The syntax for loops, #split-and-merge, etc... and basically anything which uses a replace sequence inside of it's parameters is debatable. But looping over arguments of a template is far nicer inside of things like {{See also}} than it is using a huge pile of if's and limiting the amount of input, while not helping the parser much at all.
~Daniel Friesen(Dantman, Nadir-Seen-Fire) of: -The Nadir-Point Group (http://nadir-point.com) --It's Wiki-Tools subgroup (http://wiki-tools.com) --The ElectronicMe project (http://electronic-me.org) --Games-G.P.S. (http://ggps.org) -And Wikia ACG on Wikia.com (http://wikia.com/wiki/Wikia_ACG) --Animepedia (http://anime.wikia.com) --Narutopedia (http://naruto.wikia.com)
roan.kattouw@home.nl wrote:
---- Daniel Friesen dan_the_man@telus.net schrijft:
Also, a big one. I'm thinking of actually allowing mathematical variables. These can show up in the formula, and the following parameters are var=value pairs. An example of such: {{#expr:d + v×t + ½×a×t²|d=4e2|v=2|a=4|t=7}} That kind of feature would be quite nice on perhaps... A physics wiki, where you use a lot of formula that repeat variables.
Why not just create a Template:Accmotion that contains
{{#expr:{{{d}}} + {{{v}}}*{{{t}}} + 0.5*{{{a}}}*{{{t}}}^2}}
and call
{{accmotion|d=4e2|v=2|a=4|t=7}}
Does that work? Are template parameters expanded before ParserFunctions?
Roan Kattouw (Catrope)
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
wikitech-l@lists.wikimedia.org