Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Futzing around with quotes like that is worse to type and it’s nice having distinct characters for open and close.


It makes perfect sense to have the expressions outside of the string literals, exactly because they are expressions and not literal. Quotes express literalness, the opposite of evaluation.

This is simply replacing the existing

  "My name is " + name + "."
by

  "My name is " (name) "."
by eliminating the plusses, and adding parentheses to make expressions like

  "My name is " ("John") "."
unambiguous (a string template with one parameter that happens to be a string literal). The parentheses also indicate that this is a parameter, like for a function call, that is immediately evaluated. (The whole string template feature is really just syntactic sugar for a function call.)

That way you don’t have to “interrupt” string literals with an expression. Instead you end the string literal normally and then comes an expression.

A string template would be defined as any sequence of string literals and parenthesized expressions.


I get that, but it’s hard to type accurately.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: