String interpolation available for Studio

I’ve been waiting for this for so long. It’s great to finally see it.

2 Likes

I can’t waiting to see for great updates and they needed to add more features. Thank you so much!

2 Likes

YES! Thank you, I really wanted this feature for so long…

ok well, when are we getting Object Destruction? :pleading_face:

3 Likes

Similar to python, why not make it a prefix instead of backticks?

The main concern here is it can mess up forum formatting.

local str = `foo {1 + 1}` --> doesn't look like a string at first glance

In my opinion, using a prefix look much better as backticks are quite tiny:

local str = $"foo {1 + 1}" --> using some sort of prefix
3 Likes

Like for the things you interpolate.

local s<string, string> = `{A}{B}`
1 Like

It was mentioned at the bottom of the RFC:
image
https://github.com/Roblox/luau/blob/master/rfcs/syntax-string-interpolation.md#alternatives

5 Likes

I am pretty worried that new language syntax is being marked as a Beta feature.

The entire point of static analysis, be it through studio or tooling, is to catch certain classes of bugs long before they make it into production/live testing. This not being in production means that syntax errors have the potential to make it to production, without being caught in studio or in tooling that uses luau-analyze, because of a feature that doesn’t actually work in production builds.

Excited for this feature, but I hope this can make it out of beta soon. In the meantime I can’t really write any code using it.

2 Likes

This is just my personal opinion but I doubt this will be in beta for too long…there’s just some admittedly fair risk in that this was the first piece of C++ code I had written in forever :sweat_smile:

1 Like

We don’t expect this beta feature to last very long. If there’s nothing particularly catastrophic, we might even be able to enable this immediately next week.

13 Likes

it’s good because you don’t have to use 'hi' ..tostring({1,2,3,4,5})

you instead use this

`hi {table.concat({1,2,3,4,5}, ", ")}`

Just thought I should let you know that when benchmarking, you should have os.clock in a local var to cut out the global lookup from the outputted time.

Thank you! I finally don’t have to use 20 . . signs.

1 Like

Concatenation is pretty slow and sort of unsafe. I personally opt to avoid it whenever possible. Even table.concat is apparently faster, but I stick to string.format whenever possible to avoid edge cases where my vars could be anything other than a string or number. But I digress, this will negate the need for concatenation regardless.

1 Like

Finally, Luau is Building Up a Functionality in its already rich syntax Comparable to Languages like Javascript or python.

I can’t wait to use this in all of my modules just for the sake of its simplicity i can finally change some of my [string]:format()
in my error messaging systems

When I first started using luau from previous javascript knowledge it was very annoying to not have this as a feature. Great work!

Yes!!! This is a feature I’ve been excited about for a while, and it’s amazing to finally see it added to Studio. This will help clean up so much of my code that uses concatenation, string.format, etc. Can’t wait to see it fully released!

Ya avoid using . . whenever possible. When you modify a string in Lua it will reconstruct the string each time you append to it, so if you were to append the alphabet one letter a time you’d have an expensive quadratic time complexity. If you instead use table.concat, table.format or the interpolation in OP you will instead have a linear solution by doing a single string construction at the end using a table buffer.

Lua Performance Tips has a much better explanation of this in the “About strings” header on page 8.

3 Likes

Good news! This is now out of beta and available to everyone!

25 Likes

no way, i’ve been waiting for this to happen. time to say goodbye to string.format or .. to concatenate strings together!!

2 Likes

Exactly! I’m extremely happy about this

String.format have always been one of my weaknesses, mainly because I’ve never got the hang of string patterns.

3 Likes