How is it possible for F# to examine format strings at compile time to determine that x has type int in the following definition?
let foo x = sprintf '%d' x`?
Is this hard-coded into the language or could somebody write their own ‘my_print’ function that uses format strings with a different syntax? For example:
let foo x = my_print '{integer}' x
You can read a bit about it in 6.4.17 (‘printf’ formats) here, but briefly
The net result is that you can build your own printf-style functions, but must use the same %s formats, since that stuff is built-in.