Brion Vibber wrote:
 > Any thoughts? Does anybody happen to have a PHP implementation of a
 > Lua or JavaScript interpreter?

Rather than reinventing the wheel, why not look at fixing the existing 
template syntax?

The biggest problem that I see is the excessive dependence on the 
parentheses { and }.  In a moderately complex template, you've got a mix 
of double {{...}} and triple {{{...}}} brackets, occasionally nested, 
that result in an unreadable mess.

If {{{xxx}}} was replaced with a local-variable-like syntax, say $xxx 
(where xxx is whatever name you wish, $1, $2... for unnamed), then the 
mess is reduced from something like:

{{blah|{{{xxx}}}|{{{yyy}}}}}{{#if: {{{ggg}}}|{{{h}}}|{{{4}}}}}{{{5}}}

becomes:

{{blah|$xxx|$yyy}}{{#if: $ggg|$h|$4}}$5

which is somewhat more tolerable.  (whether or not the above makes real 
sense is not my objective - I'm just trying to show how removing the 
blizzard of {{{}}} reduces visual clutter).

Since $ doesn't have a close, that makes things like {{{xxx|default 
value}}} slightly problematic, since "$xxx|$default_value" is slightly 
more awkward to parse.  But that only shows how templates are also 
overly reliant on the pipe (|) symbol - as anyone who has tried to use 
tables in templates has discovered.

If parsing templates allows the semi-restricted use of a couple of 
symbols (unlike parsing other pages - I know... don't go there), then 
both {{{}}} and | could be replaced with $ and 
I-don't-care-what-make-a-choice.  Then templates become a tad more 
readable and we get rid of kludges like {{!}} and other clutter or 
confusion in tables, parser functions, etc.

As an aside - obliging template writers to declare variables used in the 
template, say, as a definition of the input format at the top of the 
template definition, would make parsing the variables out later a tad 
easier.  If it's declared, it's a variable; if not, it's not a variable 
and is treated as plain text.  Thus the first line of a template would 
be the example of its use:

Template:foobar
----------------------------------------------------------------------
{{Foobar|$var1|$var2|$andAnotherVar}}
...(implementation)...
----------------------------------------------------------------------

But what do I know, I've only implemented one OO language compiler in my 
life and that was 20 years ago.

Mike


_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to