Open NTBBloodbath opened 1 year ago
Thanks for the interest! The point in the roadmap is probably much more minor than you think, as I mostly plan to just name temporary variables to indicate their purpose and make minor tweaks to reduce the number of newlines introduced, but for the most part the raw output will still be quite illegible.
Currently, most of the compiled code is split into separate lines because Lua doesn't report column numbers in its error messages, so when mapping errors back to their original line numbers we need to guarantee that the mapping is not ambiguous. The current implementation is somewhat naive in that it splits lines wherever an error could occur, but the benefit is that the compiler is very 'fire and forget', which keeps the code simple.
I have toyed with the idea of trying to be smarter with when newlines are introduced, depending on the provided Erde code (since we can still guarantee some non-ambiguous reverse mapping, but it will change depending on the code we are compiling). However, I have not pursued this idea greatly since I'm worried that it will introduce a lot of complexity into the codebase for little benefit (this would be quite a large change to the current compiler).
What I have recently started doing with some of my other projects is that I compile them with erde compile
, and then run the compiled output through StyLua, since I don't care much about sourcemaps when distributing the compiled code. This seems to work very nicely and is maybe along the lines of something you are looking for? I think Erde trying too hard to make the output readable may be overlapping work best left to someone else, but I also understand that this possibly requires introducing another tool.
It would be nice to either have the output not look like it's being sucked into a black hole or to pass it into a formatter automatically
Hey, hope you're doing well!
More of an issue report I want to get some feedback here to be able to help a bit with the fix whenever possible as I think you are already aware of this behavior (as I can see in #17 roadmap for 0.6.1-1 release) so I'm wondering how this could be addressed because as far as I can see in the source code this would require a refactor in how is the output code being produced in the
erde/compiler.lua
file.Cheers!