Skip to content

New feature: string interpolation #1145

Description

@Sasino97

It would be nice to add support for direct string interpolation in Teal.

This:

local val: number = 15.5
print($"value is {val}")

Would be compiled into this:

local val = 15.5
print(string.format("value is %f", val))

Of course, if you don't like the C#-like syntax above feel free to change it, but in general being able to do that is great for readability.

EDIT

I wanna add that since Teal is able to detect types, it would be easy for the compiler to choose between %s, %d, %f and so on.

For things like formatting, e.g. %0.2f or %04d, it would be nice to specify the format inside of the brackets, e.g. $"value is {val:0.2}" (compiled into string.format("value is %0.2f", val)).

Also overriding the whole type should be possible by adding the f/d/s... at the end, like $"value is {val:04d}" (compiled into string.format("value is %04d", val)), ignoring whether val is actually an integer or something else.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions