Mailing List Archive

Proposals for template language reform
In the spirit of supplying concrete examples, here are my proposed
changes to the syntax of the existing language:

* the existing {{{parm}}} or {{{parm|default}}} notation should be
changed to ${parm} or ${parm|default}

* all newlines and other multiple whitespace characters within template
source code should be regarded as reduced to single spaces, with
explicit calls to {{newline}} and {{whitespace}} operators to generate
explicit whitespace on output

These two changes alone would greatly increase the readability of
templates, both by massively reducing the number of curly brackets
within templates, and by allowing them to be formatted in a clearly
nested and indented form.

If I could add one more change, it would be an {{apply}} function, to
allow explicit calls to other templates whose names have themselves been
generated by template substitution, as used extensively in templates
such as {{coord}}; this would help clean up the semantics of the
underlying language a bit more, allowing further changes to be made more
easily both to the syntax and implementation, and also possibly allowing
a faster implementation that does not require SNOBOL-like re-parsing of
generated text.

-- Neil



_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Re: Proposals for template language reform [ In reply to ]
Neil Harris wrote:
> * all newlines and other multiple whitespace characters within template
> source code should be regarded as reduced to single spaces, with
> explicit calls to {{newline}} and {{whitespace}} operators to generate
> explicit whitespace on output
>
Just to clarify this a bit more: this whitespace compression would only
apply to whitespace contained within the template source itself:
whitespaces in text introduced from parameters or other inputs would be
preserved without compression.

-- Neil



_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Re: Proposals for template language reform [ In reply to ]
Neil Harris wrote:
> In the spirit of supplying concrete examples, here are my proposed
> changes to the syntax of the existing language:
>
> * the existing {{{parm}}} or {{{parm|default}}} notation should be
> changed to ${parm} or ${parm|default}
>
I'm not sure that would actually be parsed. And I'm no fan of leading $,
left over from the variety in PERL.

PHP isn't a model syntax that we should employ.

Actually, as the triple brace syntax is older than the parser functions,
I've never found them to be a problem. And since whitespace is already
compressed (to nothing) in the argument portion of parser functions,
I've never had a problem with adding some whitespace; that is:

{{#if: {{{1|}}}
|
|
}}

My recent surprise was the elimination of leading and trailing *newlines*
in the "then" and "else" portions, apparently only in subst'd templates,
behaving *differently* than transclusion. See my thread:

"subst'ing #if parser functions loses line breaks, and other oddities"

That thread spawned these later discussions.


> * all newlines and other multiple whitespace characters within template
> source code should be regarded as reduced to single spaces, with
> explicit calls to {{newline}} and {{whitespace}} operators to generate
> explicit whitespace on output
>
Since they are already reduced to nothing, that's a given.

I do like the idea of explicit functions {{#line:}} and {{#space:}}, with
parameters indicating the number (that is, {{#line:2}} and {{#space:2}}).

Or {{LINE:}} and {{SPACE:}} or {{LINES:}} and {{SPACES:}} or ....

This would compliment existing magic words {{padleft:}} and {{padright:}}.


> These two changes alone would greatly increase the readability of
> templates, both by massively reducing the number of curly brackets
> within templates, and by allowing them to be formatted in a clearly
> nested and indented form.
>
> If I could add one more change, it would be an {{apply}} function, to
> allow explicit calls to other templates whose names have themselves been
> generated by template substitution, as used extensively in templates
> such as {{coord}}; this would help clean up the semantics of the
> underlying language a bit more, allowing further changes to be made more
> easily both to the syntax and implementation, and also possibly allowing
> a faster implementation that does not require SNOBOL-like re-parsing of
> generated text.
>
Didn't the new parser fix that problem? Besides, SNOBOL was nifty... Once
upon a time, I was proficient. (Now, I'm not sure I remember the syntax
some 30 years later.)

_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Re: Proposals for template language reform [ In reply to ]
On Wed, Jul 8, 2009 at 8:04 AM, William Allen
Simpson<william.allen.simpson@gmail.com> wrote:
> I'm not sure that would actually be parsed. And I'm no fan of leading $,
> left over from the variety in PERL.
>
> PHP isn't a model syntax that we should employ.

Didn't the Bourne shell use a $ prefix for all variables, a decade
before Perl existed?

_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Re: Proposals for template language reform [ In reply to ]
Aryeh Gregor wrote:
> On Wed, Jul 8, 2009 at 8:04 AM, William Allen
> Simpson<william.allen.simpson@gmail.com> wrote:
>> I'm not sure that would actually be parsed. And I'm no fan of leading $,
>> left over from the variety in PERL.
>>
>> PHP isn't a model syntax that we should employ.
>
> Didn't the Bourne shell use a $ prefix for all variables, a decade
> before Perl existed?
>
Not sure, as I've been using Unix since late 1977, so my fingers mostly
remember csh. The $ is something like "contents of variable".

_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Re: Proposals for template language reform [ In reply to ]
On Wed, Jul 8, 2009 at 8:56 PM, William Allen
Simpson<william.allen.simpson@gmail.com> wrote:
> Not sure, as I've been using Unix since late 1977, so my fingers mostly
> remember csh. The $ is something like "contents of variable".

It's a way to distinguish variables from ordinary text. Shell
scripts, like wikitext, don't require string delimiters, so you can't
just make unadorned strings of letters represent variables. Other ad
hoc macro languages, like mIRC script, also tend to use some kind of
sigil for this reason. Perl might have come up with the idea of using
sigils to distinguish different types of variables, but that's not the
only reason they're useful. According to Wikipedia, BASIC may have
used sigils for that purpose before anyone else used them, though:
string variables use $, numeric variables don't. And that's well
before Unix, apparently, let alone sh or Perl.

Using sigils for wikitext would increase readability and would serve a
perfectly useful purpose, while being familiar to many users. But you
couldn't introduce it on old pages, they'd have to opt in somehow.

_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Re: Proposals for template language reform [ In reply to ]
Aryeh Gregor wrote:
> On Wed, Jul 8, 2009 at 8:56 PM, William Allen
> Simpson<william.allen.simpson@gmail.com> wrote:
>> Not sure, as I've been using Unix since late 1977, so my fingers mostly
>> remember csh. The $ is something like "contents of variable".
>
> It's a way to distinguish variables from ordinary text. Shell
> scripts, like wikitext, don't require string delimiters, so you can't
> just make unadorned strings of letters represent variables.

Not in csh. The $ /token/ is an /unary operator/ that means "contents".


> Other ad
> hoc macro languages, like mIRC script, also tend to use some kind of
> sigil for this reason. Perl might have come up with the idea of using
> sigils to distinguish different types of variables, but that's not the
> only reason they're useful. According to Wikipedia, BASIC may have
> used sigils for that purpose before anyone else used them, though:
> string variables use $, numeric variables don't. And that's well
> before Unix, apparently, let alone sh or Perl.
>
[[Sigil (computer programming)]] is/are a different concept from what we
learned in compiler class 30 years ago. According to the article, sigils
and twigils are terms that weren't coined until 1999 and later.

And BASIC only "sort of" has sigils; merely all strings end with $.
Actually, in an early implementation, all strings were a single character
followed by a $, so the symbol table could be populated with all 26
possibilities in advance....


> Using sigils for wikitext would increase readability and would serve a
> perfectly useful purpose, while being familiar to many users. But you
> couldn't introduce it on old pages, they'd have to opt in somehow.
>
Using sigils for wikitext would *DE*crease readability, as any poor soul
that had to debug Perl can attest.

{{{...}}} works, is easily distinguished from normal text, and BBedit
does a fine job keeping the braces balanced. I'm sure other editors, too.

Anything else should wait for a general scripting language, as we've been
talking about in a different thread. You're not suggesting Perl 6?

_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Re: Proposals for template language reform [ In reply to ]
On Thu, Jul 9, 2009 at 2:35 PM, William Allen
Simpson<william.allen.simpson@gmail.com> wrote:
> Aryeh Gregor wrote:
>> On Wed, Jul 8, 2009 at 8:56 PM, William Allen
>> Simpson<william.allen.simpson@gmail.com> wrote:
>>> Not sure, as I've been using Unix since late 1977, so my fingers mostly
>>> remember csh. The $ is something like "contents of variable".
>>
>> It's a way to distinguish variables from ordinary text.  Shell
>> scripts, like wikitext, don't require string delimiters, so you can't
>> just make unadorned strings of letters represent variables.
>
> Not in csh. The $ /token/ is an /unary operator/ that means "contents".
>
>
>> Other ad
>> hoc macro languages, like mIRC script, also tend to use some kind of
>> sigil for this reason.  Perl might have come up with the idea of using
>> sigils to distinguish different types of variables, but that's not the
>> only reason they're useful.  According to Wikipedia, BASIC may have
>> used sigils for that purpose before anyone else used them, though:
>> string variables use $, numeric variables don't.  And that's well
>> before Unix, apparently, let alone sh or Perl.
>>
> [[Sigil (computer programming)]] is/are a different concept from what we
> learned in compiler class 30 years ago.  According to the article, sigils
> and twigils are terms that weren't coined until 1999 and later.
>
> And BASIC only "sort of" has sigils; merely all strings end with $.
> Actually, in an early implementation, all strings were a single character
> followed by a $, so the symbol table could be populated with all 26
> possibilities in advance....
>
>
>> Using sigils for wikitext would increase readability and would serve a
>> perfectly useful purpose, while being familiar to many users.  But you
>> couldn't introduce it on old pages, they'd have to opt in somehow.
>>
> Using sigils for wikitext would *DE*crease readability, as any poor soul
> that had to debug Perl can attest.
>
> {{{...}}} works, is easily distinguished from normal text, and BBedit
> does a fine job keeping the braces balanced. I'm sure other editors, too.
>
> Anything else should wait for a general scripting language, as we've been
> talking about in a different thread.  You're not suggesting Perl 6?
>
> _______________________________________________
> Wikitech-l mailing list
> Wikitech-l@lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>

Maybe it's just me, but I would find $var much easier to read and
understand than {{{var}}}.

-Chad

_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Re: Proposals for template language reform [ In reply to ]
Chad wrote:
> On Thu, Jul 9, 2009 at 2:35 PM, William Allen
> Simpson<william.allen.simpson@gmail.com> wrote:
>> {{{...}}} works, is easily distinguished from normal text, and BBedit
>> does a fine job keeping the braces balanced. I'm sure other editors, too.
>>
>> Anything else should wait for a general scripting language, as we've been
>> talking about in a different thread. Â You're not suggesting Perl 6?
>
> Maybe it's just me, but I would find $var much easier to read and
> understand than {{{var}}}.

It's not just you and examples I previously posted should show how $
prefixes are easier to read than a {{{-little-nest-of-vipers when more
than one variable (possibly nested) shows up.

The use of BBedit or other editors is irrelevant, since templates are in
the wiki editor.


Mike


_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Re: Proposals for template language reform [ In reply to ]
> Maybe it's just me, but I would find $var much easier to read and
> understand than {{{var}}}.
>
Me too, even if my voice doesn't really counts (as I am not from WF).
Readability is very important thing that helps to re-use the code and to
make less bugs.
Dmitriy

_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l