On 29.05.2012 18:54, Gabriel Wicke wrote:
On 05/29/2012 06:33 PM, Daniel Kinzler wrote:
Both the
PHP preprocessor and Parsoid rely on template expansions being
purely functional for a single parser pass (see for example line 118ff
in Preprocessor_DOM.php). This means that a full expansion subtree can
be reused / cached if the parameters match.
Thanks for providing details here!
This would be the case, since the local "variable" indicating the
"local"
default item would be set using a parser function call in the template, and
would depend solely on the template parameters (or, trivially, use a static item
id).
This is not true for subtemplates of such a wrapper template, unless you
completely disable caching for those or handle expansion yourself.
Ah, of course. Good point, thanks!
It is possible to add scoped variables, but we'd
have to carefully
consider the implications for caching, implementation complexity and
usability.
Since the scoped var does not depend on any external information besides
template parameters, I don't expect problems here.
One problem I see is that the value of the variable in a local scope
would change during execution. Parsoid expands templates and parser
functions in parallel, so you would get non-deterministic behavior
depending on the order of execution.
So that basically means the default item should be changed only once, and only
at the beginning, of a template, and this would have to be evaluated before
evaulating anything else in that template. Hm, that sucks.
-- daniel
--
Daniel Kinzler, Softwarearchitekt
Wikimedia Deutschland e.V. | Eisenacher Straße 2 | 10777 Berlin
http://wikimedia.de | Tel. (030) 219 158 260
Wikimedia Deutschland - Gesellschaft zur Förderung Freien Wissens e.V.
Eingetragen im Vereinsregister des Amtsgerichts Berlin-Charlottenburg
unter der Nummer 23855 B. Als gemeinnützig anerkannt durch das Finanzamt
für Körperschaften I Berlin, Steuernummer 27/681/51985.