Add functions to print/error formatted strings

As a Roblox developer, it is currently annoying to output meaningful information when printing or throwing an error because of how verbose it is. It’s often important to have output information contain variables, but at the moment it’s annoying to do this. A situation like print("foo", bar, "baz") is rather common which, while okay, doesn’t provide any control over what the output looks like.

For error, it’s even worse because it doesn’t accept a vararg, so you end up doing something like error("foo"..tostring(bar).."baz") instead.

To combat this, I often end up defining helper functions to format printed and thrown messages. Something like printf from C. It would help my development process greatly if something like this was built-in instead since I wouldn’t have to go through an annoying setup to properly format my output.

4 Likes

It would be awkward for error to accept variable arguments because error takes an addition level argument. The error object can also be something which isn’t a string, which makes it weird to combine them. If there was something like errorf it should also come with a level argument which would make something like errorf("foo %i baz",bar) invalid, and that would be quite unexpected.

1 Like