Any reason template string with empty interpolation placeholder (`${}`) throws?

Domenic Denicola d at
Thu Oct 22 23:26:21 UTC 2015

If there were to be a value for `${}`, `undefined` makes more sense to me than the empty string as a default “nothing” value.

From: es-discuss [mailto:es-discuss-bounces at] On Behalf Of Caitlin Potter
Sent: Thursday, October 22, 2015 19:20
To: Mark S. Miller <erights at>
Cc: es-discuss at
Subject: Re: Any reason template string with empty interpolation placeholder (`${}`) throws?

Cute, but nobody is realistically going to do that.

Possible valid uses for the empty placeholder:

- Contents of expression commented out, maybe debugging if it causes side effects which may be harmful
- Expression is a placeholder, with contents soon to come (mentioned by OP)

The DSL thing is a non-issue, because the empty expression didn't need to be included in the list of expressions, and if it is included, DSLs can be smart enough to deal with it, and should probably be implemented as a recursive descent parser on top of the interpolated text anyways

Ease of use, ease of debugging, ease of editing. Users of JS don't make the distinction between a Statement and Expression or ExpressionStatement, and interpolated strings are very much about strings.

On Oct 22, 2015, at 7:05 PM, Mark S. Miller <erights at<mailto:erights at>> wrote:
It is an unnecessary special case. The empty string is a valid statement (aside from the semicolon) but not a valid expression. The syntax of what appears between the curlies is expression.

Having it default to the empty string makes no sense. Why not 0, false, null, or undefined? Remember that template strings can be used to make arbitrary objects using any DSL that your tag knows how to parse. There's nothing about template strings that is about strings in either the substitution values or the result values.

If you want the equivalent of `${''}`, just say `${''}`.

On Thu, Oct 22, 2015 at 6:31 PM, Caitlin Potter <caitpotter88 at<mailto:caitpotter88 at>> wrote:

Doesn't necessarily seem like a bad idea. I could be on board with that.

> On Oct 22, 2015, at 6:18 PM, Mohsen Azimi <me at<mailto:me at>> wrote:
> Pardon my lack of use of proper terminology.
> This is kind of annoying working with large template strings. When I leave an interpolation placeholder(what's the right name?) empty it blows up all my code.
> Can it be forgiving like Ruby and CoffeScript and just replace it with empty string?
> _______________________________________________
> es-discuss mailing list
> es-discuss at<mailto:es-discuss at>
es-discuss mailing list
es-discuss at<mailto:es-discuss at>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list