dbaumgarten / yodk

Development Kit for Starbase's ingame programming language YOLOL
MIT License
57 stars 16 forks source link

Remove unused local variables/expressions #63

Open Woccz opened 3 years ago

Woccz commented 3 years ago

Any local variable or expression that has no effect on a global variable can be removed.

i.e.

The first implementation of this could merely remove any locals that are never evaluated, in any context.

image

Note: Obviously, any competent programmer can remove useless expressions from their code, but with libraries and other code reusability(e.g. #62), this maybe be a helpful optimisation.

Thank you.

dbaumgarten commented 3 years ago

Finding out of a variable somehow influences a global should be possible, but probably requires some effort to do it properly. Removing assignments to variables that er never referenced would be a good first step.

Given that this will not be used very often and would require relatively much work: backlog