Fable
Fable copied to clipboard
Simplify printfn usage when applied a constant string in Fable 3
Description
Simplify printfn usage when applied a constant string to plain console.log
when there is no custom formatting work to be done:
printfn "Hello"
compiles to
String_toConsole(String_printf("Hello"));
Instead compile to just
console.log("Hello")
by detecting the constant string usage in the AST.
Let me give this one a try too :)
- Fable version: 3.0.0-nagareyama-alpha-015
- Operating system: Windows 10
Ok, please feel free to give it a go. Hopefully Fable is easier to contribute now :) Just a note of caution though, dealing with the print formatters is quite complicated because the F# compiler creates many closures around them and it's quite difficult to identify the AST for them. I've trying to simplify/optimize print formatters since the very first version of Fable, but at the end I opted for simplicity. We're also trying to remove complicated patterns in the FSharp2Fable step because accessing FCS BasicPatterns
can be slow sometimes.