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:[email protected]] On Behalf Of Caitlin
Potter
Sent: Thursday, October 22, 2015 19:20
To: Mark S. Miller <[email protected]>
Cc: [email protected]
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
<[email protected]<mailto:[email protected]>> 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
<[email protected]<mailto:[email protected]>> 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
> <[email protected]<mailto:[email protected]>> 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
> [email protected]<mailto:[email protected]>
> https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]<mailto:[email protected]>
https://mail.mozilla.org/listinfo/es-discuss
--
Cheers,
--MarkM
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss