mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.27k stars 1.51k forks source link

string.format() with identity-expressions #13126

Open akaessens opened 1 week ago

akaessens commented 1 week ago

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
QuLogic commented 1 week ago

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().