Skip to content

Comment on Elvish – Scripting language and interactive shellparent

Comments

what can string interpolation do that i can't also do by sandwiching a variable between strings: 'string1'$var'string2'?

string interpolation is useful where concatenating strings requires an operator, but i don't see the benefit otherwise.

for more complex examples i can use printf, or someone could write a function that does string interpolation. since there is no need to fork, that should not be that expensive

I mostly agree, but in Bash for example "string1${var}string2" guarantees to be a single argument, which 'string1'$var'string2' doesn‘t (when $var contains whitespace). So it entails certain other language design choices.

in bash yes, so that makes sense. thanks for pointing that out. in elvish $var is guaranteed to remain one string, and so 'string1'$var'string2' is always going to remain one argument too.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.