Format Specification for String Interpolation#208
Conversation
|
I can't help but feel like this syntax is still a bit awkward. I understand why other delimiters weren't chosen, but I'm not sure this approach would be preferred over current options. local balance = 100.3921
print(`You have ${string.format("%.2f", balance)} in your bank account.`) |
|
|
|
Not that I'm a fan of it, but Wonder if Scala style is a good choice of the separator: |
|
Would |
|
Oh yes 😅 |
|
It would be interesting to see what characters are even available to be used in this position. We've got |
This is what I was getting at in the document. I agree it’s not pretty but it ‘works’.
This might just end up being the best choice, considering that the Luau team seems to want #170. I’ll likely close this if that ever gets merged.
In the document there’s a small list, I think the only ones I would ever consider are
At the very bottom of the document I off-handedly mentioned this. I really wish there was some way for this to work, because I think that it would be the best delimiter. There is the evil option of doubling up on it like |
|
The semicolon is fine with me. It is the only reasonable option that is both backwards and forwards compatible, and the only real argument against it is that it looks odd. With regards to #170, I think the burden of supporting specifiers should be on that RFC instead of OP. Specifiers are a more ubiquitous feature than structured logging, and personally I don't like how the desugaring in that RFC works. If there should be any interest in it again, a more fleshed out version of "interpolated destructuring" should be made that properly incorporates or at least leaves room for specifiers. |
I had this one on the backburner for a while. It's basically just an exact rehash of #20 but uses
;as the delimiter. I've taken some examples from it.I'd really like to hear thoughts on this again because it keeps on popping up in my projects and feels trivial to add.
I'm leaving this as a draft pull request for now in case some people really do not like
;. I feel impartial to it myself.Rendered.
Example