Quasi-literals for templating?

Bob Nystrom rnystrom at google.com
Wed Jun 15 16:39:56 PDT 2011

On Wed, Jun 15, 2011 at 4:31 PM, Mark S. Miller <erights at google.com> wrote:

>  The shorthand {x, y} for {x: x, y: y} allowed on the left-hand side of
> assignment should be allowed on the right too ...
> This shorthand has nothing to do with quasis per se. It's just a convenient
> expression syntax. So if we allow more expression syntaxes to appear between
> `...${ and }...` and if this "more" includes this specific syntax, then we
> can compose then to give the requested information conveniently without
> violating alpha-rename-ability.

That shorthand does, I think, beg for a slight change to the quasi syntax.
Within a quasi, curly braces are currently used to mean grouping instead of
an object literal. So if you want an argument that is an object literal, you
have to double curly it: "${{foo}}".

Instead, how about:

// old   new
$foo     $foo
${a + b} $(a + b)
${{x}}   ${x}

So, within a quasi, a $ can be followed by an identifier, an expression
grouped using parentheses (like they usually are) or an object literal (in
curlies like it usually is). Using curlies as a grouping character in quasis
always seemed a bit strange to me anyway, since they aren't used that way
elsewhere in the language.

- bob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110615/bb0d3fc4/attachment-0001.html>

More information about the es-discuss mailing list