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

Caitlin Potter caitpotter88 at gmail.com
Fri Oct 23 01:06:30 UTC 2015


I’m not making a claim about history, I wasn’t in the room when they were presented. It’s a claim about creating something that was never really needed by the vast majority of users. It’s nice to have, but it’s not the most useful aspect of template literals/quasi literals. It makes the spec more complicated, and makes changing it more difficult (particularly in this case, where it could change the # of expressions passed to a tag, depending on how it were spec’d, if it were ever added to the specification).

It’s clearly something that most programmers have no use for in their own projects. While it is certainly nice to have, I don’t think it can be considered the main point. It does little to make anyones work simpler, whereas multiline strings and ${…} expressions are easir to read and understand, compared to how they were done previously.


> On Oct 22, 2015, at 9:00 PM, Mark S. Miller <erights at google.com> wrote:
> 
> 
> 
> On Thu, Oct 22, 2015 at 8:58 PM, Caitlin Potter <caitpotter88 at gmail.com <mailto:caitpotter88 at gmail.com>> wrote:
> The history does not matter.
> 
> Excuse me. "Tagged templates were an addition" sounded like a claim about history.
> 
> 
> It doesn’t make a difference what someone presented or argued for to a room full of people. What matters is how they’re actually used in practice.
> 
> There are some libraries which do some clever things with them. They are not common, there are not a lot of them, and they don’t necessarily perform their tasks easier than a simple recursive descent parser would.
> 
> The main use is absolutely string interpolation.
> 
>> On Oct 22, 2015, at 8:56 PM, Mark S. Miller <erights at google.com <mailto:erights at google.com>> wrote:
>> 
>> 
>> 
>> On Thu, Oct 22, 2015 at 8:54 PM, Caitlin Potter <caitpotter88 at gmail.com <mailto:caitpotter88 at gmail.com>> wrote:
>> > JavaScript does not have string interpolation. It has arbitrary value interpolation.
>> 
>> Disagree. `foo ${bar} baz` is string interpolation. `${bar}` becomes `ToString(bar)`. Tagged templates were an addition
>> 
>> That is not the history.
>> 
>> 
>> that weren’t really needed.
>> 
>> Disagree. They were and are the main motivation. The fact that the unmarked case does string interpolation is just icing on the cake.
>> 
>> 
>> 
>> Since they exist, great, people can come up with some clever uses for them. But they’re hardly the common use case, which is definitely string interpolation
>> 
>>> On Oct 22, 2015, at 8:43 PM, Mark S. Miller <erights at google.com <mailto:erights at google.com>> wrote:
>>> 
>>> JavaScript does not have string interpolation. It has arbitrary value interpolation.
>>> 
>>> 
>>> On Thu, Oct 22, 2015 at 8:34 PM, Caitlin Potter <caitpotter88 at gmail.com <mailto:caitpotter88 at gmail.com>> wrote:
>>> Okay, but usability wise, this kind of sucks. There's a reason it's not what people expect, and why other languages with string interpolation behave differently.
>>> 
>>> On Oct 22, 2015, at 8:24 PM, Allen Wirfs-Brock <allen.wirfsbrock at gmail.com <mailto:allen.wirfsbrock at gmail.com>> wrote:
>>> 
>>>> 
>>>>> On Oct 22, 2015, at 4:55 PM, Mark Miller <erights at gmail.com <mailto:erights at gmail.com>> wrote:
>>>>> 
>>>>> 
>>>>> 
>>>>> On Thu, Oct 22, 2015 at 7:20 PM, Caitlin Potter <caitpotter88 at gmail.com <mailto:caitpotter88 at gmail.com>> wrote:
>>>>> Cute, but nobody is realistically going to do that.
>>>>> 
>>>>> Since `${}` is a static error, what do you realistically think people will do? Especially if they meant `${''}`, how do you expect them to react to the static error?
>>>> 
>>>> Just like they do if they have a line of code that reads:
>>>> 
>>>> ```js
>>>> str = ;
>>>> ```
>>>> 
>>>> when they meant
>>>> 
>>>> ```js
>>>> str = ‘’;
>>>> ```
>>>> 
>>>> It’s just a syntax error.  I probably have syntax errors in 50% of the lines that I initially type.  I parse, and then fix.
>>>> 
>>>> Allen
>>>> 
>>> 
>>> 
>>> 
>>> --
>>>     Cheers,
>>>     --MarkM
>> 
>> 
>> 
>> 
>> --
>>     Cheers,
>>     --MarkM
> 
> 
> 
> 
> --
>     Cheers,
>     --MarkM

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20151022/185fe7f1/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20151022/185fe7f1/attachment.sig>


More information about the es-discuss mailing list