meson icon indicating copy to clipboard operation
meson copied to clipboard

string.format() with identity-expressions

Open akaessens opened this issue 4 months ago • 1 comments

With fstrings we can format identity expressions:

a = 1
string = f'@a@'

Positional arguments with string.format()

a = 1
'@0@'.format('a')

In our use case, we want to format strings with identity expressions. We use a native file with meson.get_external_property(). The name property may contain @a@.

string = meson.get_external_property('name', 'default')

string.format() # this should replace identity expressions, i.e. @a@ -> 1

akaessens avatar Apr 22 '24 08:04 akaessens

~~That's get_variable(string), is it not?~~ Edit: actually, I misread, but:

Positional arguments with string.format()

a = 1
'@0@'.format('a')

doesn't produce 1, but a, so I'm not sure about the logic that ends with string.format().

QuLogic avatar Apr 22 '24 21:04 QuLogic