Open wende opened 6 years ago
I'd definitely output AST, feed that through Macro.to_string
then feed that through Code.format_strring!
.
Removes the possibility of doing dirty tricks with the code (double edged sword though)
Actually this is entirely incorrect. Elixir itself is a reduced syntax, the AST can actually represent a lot of code that is just entirely invalid in Elixir's syntax itself (obviously you'd want to make sure to put in appropriate unquote
's and such in the AST to allow the syntax itself to properly represent it if you want to format it). :-)
Since this card requires Elixir parts that'd mean it first needs Elchemy to be run in its self-hosted version or we'd need to store the AST in intermediate files. Either way it's a too low in terms of bang for the buck ratio for right now.
It should stick around here until it's time for it though
Back when Elchemy started a year ago producing an output as a binary was an obvious choice because of readability. Right now, however, with an Elixir formatter being built-in and generally much nicer tools to produce readable code out of AST it's worth considering if overhauling the compiler from
to
Pros:
Cons