Error in execution

Hi all, been seeing the following log message and trying to decipher: “ERROR: stack overflow, cannot resize stack while in a metamethod” I am not using any meta programming and have reverted back to blinkenlight to try to clear but still see. Any ideas? Thanks.

While we haven’t pinned down exactly why certain seemingly-straightforward programs trigger this error, one “risk factor” seems to be having lots of variables declared “local” at the top level, i.e. outside any function. Such declarations actually do something quite unusual in Squirrel, and if you do have a lot of lines (not in functions) that look like this:
local s = 0;
then the code would probably still work, just more efficiently, if you changed them to:
s <- 0;
i.e., in Squirrel’s vocabulary, “introducing new slots in the root table”.

And yes, tons and tons of our own example code is full of such local free variables. That’s because we didn’t initially realise how it worked!


So anything declared outside a function should use <-?
I have a couple of objects I create at the top level and some config data (logging level, etc, which can change with a config change)…

Maybe we need a squirrel “best practices” article…

We certainly do need such an article. I’m still working out what we need to write in it!


Bit like this, maybe:


Perfect! Thanks!

Really we should add logging or a callback or something for determining the memory currently in-use, so that everyone can try things to optimise their own squirrels – without the first indication of an inefficient coding technique being a non-running program :frowning:


Yes, yes! I like it.