Using _ENV to cut down on "self"

I've been playing around with PICO-8 for a project and came across a bit of code from Kevin Thompson that reassigns the _ENV variable to allow objects to cut down on all the uses of self in code.

I tried it out in a Playdate project and it seems to work! I feel like my code is so much more legible without all the self clutter. I haven't done any serious benchmarking because it's a relatively simple project and haven't run into any problems on device, but I'm wondering if any of y'all can foresee issues with going this route.

I'm also wondering if someone who understands LUA's metatable magic a bit better has ideas for how to incorporate this into the existing Playdate SDK object class so that I could get the benefit of both worlds, or if they are too incompatible?

5 Likes