Since when is "\(var)"
valid string interpolation?
I have been playing with AI agents writing roc code by piping in the tutorial, and have discovered that Claude likes to write "\()
for string interpolation, and it works!
This is not mentioned as valid syntax in the tutorial, but I have seen Claude write this repeatedly, and to my surprise it actually interpolates the value, and the \
is not printed.
String interpolation syntax used to be "\(var)"
, and recently support was added for "$(var)"
, I believe because it's better known. The old syntax is still around, I imagine at some point we'll remove it.
that's right
the reason was more because it gets hard to read in the common case where you're using it with slashes, e.g. in a file path "foo/\(name)/bar"
vs. "foo/$(name)/bar"
also it was annoying for some vim keybindings
Ahh.. Thanks! That makes total sense.
Ian McLerran has marked this topic as resolved.
We should make an issue to track that and remove it. I think it's probably ok to remove already, as it's been a while.
agreed!
only argument I can see against it is if we want to wait until an 0.1 release to remove it
so that like "pre-0.1 Roc" Advent of Code solutions still work
Ian McLerran has marked this topic as unresolved.
"pre-0.1 Roc" Advent of Code solutions still work
Those probably are broken already anyway. Task as builtin, basic cli changes, etc
I agree with Brendan. For breaking changes until we reach some 0.1 more "stable" version of Roc, we should try to provide backwards-compatible changes (like Agus' new header syntax that re-formats the old syntax to the new one), and just make announcements for breaking changes like the Task changes. Otherwise, there are gonna be a lot of breaking changes soon (purity inference, try
vs ?, etc.) that will be slowed down trying to think of breaking code less than it is already broken.
fair point!
Brendan Hansknecht said:
"pre-0.1 Roc" Advent of Code solutions still work
Those probably are broken already anyway. Task as builtin, basic cli changes, etc
Don't forget about Nat
. I think this is the main reason, that none of the old AoC files work anymore
FWIW I like to go back and update my AoC examples before Dec so people have some working examples. I did it last year and it was really interesting to see how much had changed in only 1 year. :smiley:
Luke Boswell said:
We should make an issue to track that and remove it. I think it's probably ok to remove already, as it's been a while.
Issue logged https://github.com/roc-lang/roc/issues/7148
Last updated: Jul 06 2025 at 12:14 UTC