5 ms·
I don't think Nim has one in the standard library, but people have built variations on it. Here's a couple: * https://github.com/bluenote10/nim-stringinterpola
by simen 8y ago
I don't think Nim has one in the standard library, but people have built variations on it. Here's a couple:
* https://github.com/bluenote10/nim-stringinterpolation/blob/master/stringinterpolation.nim https://github.com/bluenote10/nim-stringinterpolation/blob/m... This one does string interpolation and a printf-like syntax with compile time type checking. It does call out to C but only after it's already parsed and validated and transformed the format string.
* https://github.com/kaushalmodi/strfmt/blob/master/strfmt.nim https://github.com/kaushalmodi/strfmt/blob/master/strfmt.nim This one implements a more complex string formatting syntax with lots of convenience functions. It's more complex but provides a lot more functionality than the previous one without relying on FFI.
I'm not a Nim programmer but I imagine those two demonstrate how Nim metaprogramming works even if neither exactly duplicates the behavior of printf.
- dom96 8y agoNim also has this in the stdlib now: https://nim-lang.org/docs/strformat.html https://nim-lang.org/docs/strformat.html