dansanderson / picotool

Tools and Python libraries for manipulating Pico-8 game files. http://www.lexaloffle.com/pico-8.php
MIT License
367 stars 46 forks source link

"Alias"-ing of built-in PICO-8 functions? [Suggestion] #21

Open Liquidream opened 7 years ago

Liquidream commented 7 years ago

Hiya,

Just a suggestion: rather than excluding built-in PICO-8 functions from being "minified", could luamin instead create a shorter "alias" to them? Such as... pr=printh pr("hello world") This is a technique I normally use from time to time to reduce the overall character count.

Now, I guess this would only be beneficial if a particular function is called more than a couple of times (to warrant the overhead of the alias), but just thought that, if possible, this might be a way to further reduce the final output's footprint.

At the very least, it would be nice if luamin wouldn't "break" the code when I setup a function alias (which seems to happen currently).

Anyways, just a thought. :wink:

dansanderson commented 6 years ago

The suggestion is plausible and it wouldn't be too difficult to count uses and only add the alias if it's productive. I'd be curious to do a keyword counting sweep over a large set of carts to estimate real world gains.

Can you elaborate on the last bit about the current behavior breaking aliases?

pr=printh
pr("hello world")

currently minifies correctly to

a=printh
a("hello world")

Do you have an example that breaks?