PlutoLang / Pluto

A superset of Lua 5.4 with a focus on general-purpose programming.
https://pluto-lang.org/docs/Introduction
MIT License
339 stars 20 forks source link

Optimize boolean massage #748

Closed Sainan closed 3 months ago

Sainan commented 3 months ago

This is a very minor thing, but when the user writes !!x (or not not x), currently, the generated code is just trivially doing the not operation twice, but it might be possible to generate more optimal code for this.

well-in-that-case commented 3 months ago

The compile-time concat optimization reinforced a lesson: these types of 'optimizations' have more to lose than gain and aren't worthwhile.

Sainan commented 3 months ago

I agree that this optimisation would be close-to-useless, although the compile-time concat definitely had a bit more reason for exisitng, and there's no reason for us to not re-add it at some point in the future, if we can do so without bugs.

Closing this because I can't think of a trivial way to implement this that would be provably bug-free.