You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
String formatting functions sprintf, printf, etc. are popular in F# code, but currently slow and aot-unfriendly, implemented using reflection and dynamic codegen.
They should be implemented with consideration for performance, and for compatibility in reflection-constrained environments.
Most commonly sprintf occurs in conjunction with a known format string. Therefore one approach would be to recognize the pattern sprintf specificStringFormat and compile this combination.
Pros: performance and aot-compatbility
Cons: adds code to maintain, as removing the existing approach would be a breaking change.
typeR={ Field:int }letprintR:R ->string =// Matches `sprintf specificStringFormat` so is compiled
sprintf "r is %A"letprintTwice<'a>(f:Printf.StringFormat<'a->string>)(x:'a)=lets=// Not compiled and uses existing approach, since `f` is not known statically.
sprintf f x
s + s
The text was updated successfully, but these errors were encountered:
Closing temporarily in favour of fsharp/fslang-suggestions#919 which is likely to be more natural to implement in the short term and a stepping stone to sprintf compilation.
String formatting functions
sprintf
,printf
, etc. are popular in F# code, but currently slow and aot-unfriendly, implemented using reflection and dynamic codegen.They should be implemented with consideration for performance, and for compatibility in reflection-constrained environments.
Most commonly
sprintf
occurs in conjunction with a known format string. Therefore one approach would be to recognize the patternsprintf specificStringFormat
and compile this combination.Pros: performance and aot-compatbility
Cons: adds code to maintain, as removing the existing approach would be a breaking change.
The text was updated successfully, but these errors were encountered: