Open Smaug123 opened 1 month ago
Do you have need for sprintf in preference to interpolated strings? It would be better to focus effort on improving interpolated strings (by making them work via a string collector) than working on sprintf which is generally unsalvageable.
Yeah, I write source generators and am not really willing to break compatibility for my (completely uncontrolled) consumers. I could of course parameterise the generators or do some work to make available to them the current version of F#, or more practically I could just accept that there are bugs and manually call ToString on everything; that's certainly not the end of the world.
F# 5.0 with string interpolation was released 2020. Can't imagine why anyone would be using previous versions at this point.
Anyway the options are:
F# 5.0 with string interpolation was released 2020. Can't imagine why anyone would be using previous versions at this point.
Partial application is one thing you can't do with interpolated formatting.
sprintf "%b" true
does not work in AOT context; nor doessprintf "%O" true
. This affects linux-x64 8.0.401 and v9 preview 1, but not osx-arm64 8.0.300, in my testing.Repro steps
In an executable with
<PublishAot>true</PublishAot>
:Expected behavior
Program prints "true".
Actual behavior
Known workarounds
(fun s -> $"%O{s}") true
works, as doesx.ToString () |> sprintf "%s"
.Related information
Reproduced on linux-x64 with net8.0.401 and net9 preview 7, but not osx-arm64 8.0.300.