Closed pancelor closed 1 year ago
I'll give this some thought, thanks.
hmm, I've just realized that I use DIR as "direction" all the time (and I've seen it in others' code too) and it'd be a bit annoying for that to not be minified... but it is a sometimes-useful function -- I know people have built their own splore-likes using it. on the other hand, LS is mentioned in the manual (including runtime usage) while DIR is not...
I don't feel too strongly about most of this commit, but I do think the tostring
part should be merged -- it caught me offguard a week ago, and a few days ago I was helping someone use shrinko8 for the first time and it gave them a very confusing error: "attempt to call global 'ol' (a nil value)" on a huge minified line of code, with no clear way to track down what on earth that meant, as a beginner. (this was before they had gotten shrinko8 to successfully shrink any carts)
'ls' makes sense, 'tostring' I'm less sure about (it did seem to survive a good while, but I wouldn't be surprised if it goes away one version; plus I could see it being used for custom functions) but okay - merged, thanks. I think I'll also add an undocumented --not-builtin to allow to override this sort of thing. (There's already an undocumented --builtin) Ideally shrinko8 could try to analyze which builtins are definitely assigned before they're accessed and automatically treat them as custom globals, but that could run afoul of _ENV shenanigans...
tostring() works in pico8 (0.2.5g). It seems like an oversight but shrinko8 should not rename it; it's very easy to accidentally use tostring() instead of tostr(), which creates errors like "attempt to call global 'ol' (a nil value)" after running through shrinko8
after fixing this, I checked to see if there were any other globals:
for k,v in all(_𝘦𝘯𝘷) do printh(k.." : "..tostr(v)) end
I added a few (ls, etc) but also found a bunch more; I'm not sure if these should be added or not:
(most of them seem useless / nonfunctional from within a cart, but they also don't throw errors, and if shrinko8 renames them then they'll throw nil function errors... but they also don't seem to fit the names "deprecated_globals" or "undocumented_globals")