tomhrr / dale

Lisp-flavoured C
BSD 3-Clause "New" or "Revised" License
1.03k stars 48 forks source link

difference between auto and intern variables? #78

Closed porky11 closed 8 years ago

porky11 commented 8 years ago

I assumed that all intern variables are allocated at compile time and are only accessible from the creating namespace, like the containing function, and auto variables are created at runtime on the stack. but when using an intern variable inside a function, it will be set to it's initial value every time the function is called, so it is not as I expected, that they can be used like static variables in c. what do auto variables mean then?

tomhrr commented 8 years ago

On Thu, Sep 01, 2016 at 09:32:25AM -0700, Fabio Krapohl wrote:

I assumed that all intern variables are allocated at compile time and are only accessible from the creating namespace, like the containing function, and auto variables are created at runtime on the stack. but when using an intern variable inside a function, it will be set to it's initial value every time the function is called, so it is not as I expected, that they can be used like static variables in c. what do auto variables mean then?

Thanks for reporting this. Your initial understanding was correct, or at least, that's how it was meant to be operating. The problem was that intern function-scoped variables were being treated as if they had been declared with auto, hence the problem. This has now been fixed.