Template strings and templates

John J Barton johnjbarton at johnjbarton.com
Sun Aug 5 12:11:21 PDT 2012

On Sat, Aug 4, 2012 at 1:22 PM, Mark Miller <erights at gmail.com> wrote:

> It is a matter of definition and taste, but I don't think it is useful to
> think of these as macros. I expect macros to extend the base language as if
> adding new special forms, where these special forms are stylistically
> similar to the existing special forms. For example
> myfor (x of xs) {
>   print(x);
> } between {
>   print(',');
> }
> or
>     expr ||| expr

Such a macro capability would go quite beyond what most practitioners
imagine when they hear 'macro'. I guess they imagine either C macros or "a
scripting language".

> For quasi-literals, first, I agree that "quasi" anything is not a good
> choice and that "string template" is better. The suggested analogy to other
> things called templates seems more useful. But best I think would be
> terminology that suggests that this is a generic DSL embedding mechanism,
> where you can escape back into the host language from holes in the guest
> language.

You just made the argument that this feature is so limited that it isn't a
generic DSL embedding mechanism. Really the 'DSL' syntax here is much
closer to clunky MACRO() than to "embedded language".  However I like the
mental image you give in "embedding mechanism, where you can escape back
into the host language from holes in the guest language."  Maybe more
descriptions will help a better name emerge. Here is my try:

The feature combines a new string-definition syntax with a new
function-calling syntax. Backticks are quotes with multi-line powers and
they are parens for the new function calls; $/${} supplants comma as an
argument separator. The functions called with backticks always receive an
array argument with odd length and elements that alternate between strings
and values.

That makes me think 'template'. However 'string template' for me generates
strings; and 'template string' is redundant by repeating itself. (On the
other hand, this feature without strings would just a silly way to call a

Another direction: Joe Hewitt's system for generating the Firebug UI was
'domplate', an invented word that use 'plate' to evoke 'template' and 'dom'
since it generated DOM elements. Since this feature is not limited to DOM
elements, maybe combine 'plate' with another noun to identify the kind of
template here. "Backplate" anyone?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120805/8250bb77/attachment.html>

More information about the es-discuss mailing list