It looks to me like this doesn't even need to be a stack. This just needs to be a flag of whether you're in a function or not. I only see push/pop and tests whether the length is greater than 0, nothing actually reads this stack of names.