Appcelerator and CommonJS modules (caching and circular references)
Here's the thing: I'm using the CommonJS way of making my mobile (iPhone/Android) application modular. No surprise there. But there's one thing that I just can't get my head around. CommonJS lets me create STATIC private variables, which lets me create singletons at ease. This, I think at least, is because the contents of a file that gets require() d is read only once and then the exports object (which is initialized only once) is returned every time. But when I create a circular reference as seen below, the code inside the included module is executed every time. Wait... Funny thing is, while