Reduce unnecessary gensym locals

The compiler currently binds values to gensym locals indiscriminately, leading to clutter in the compilation output. This is motivated by a need for idempotency, but many of these bindings are unneeded because they're symbols or literal values.

Across the "fennel-compendium" repository, which contains all Fennel games for TIC-80 and love2d ever to be submitted to a lisp game jam, we can see there are 496 unnecessary bindings. We should see if we can bring that number down.

https://p.hagelb.org/aotall.lua https://git.sr.ht/~technomancy/fennel-compendium/commit/f7a6886fc2ebfdccf0d1c87690850180a956e56f

Assigned to
1 year, 1 month ago
10 days ago

~xerool 1 year, 1 month ago

I've made a patch for case/match which gets rid of a lot of these bindings. That brings us down to 286 total unnecessary bindings.


The next 277 of them are caused by destructure. Then, 8 of them are from -?> (mostly because -?> is used in fennelview) The last one is because someone wrote (match true ...). I don't mind if we leave the gensym around for that one.

~xerool referenced this from #199 a month ago

~technomancy REPORTED CLOSED 10 days ago

Between your case/match and my recent destructuring gensym fix, the number found by make countgensym above has gone down to only one. There are surely other unnecessary gensyms, but I think we can close this one out.

Register here or Log in to comment, or comment via email.