classes vs. require and how to destroy them?

Hello!

This might be a bit odd question but most of the stuff I found is on creating objects rather than destroying them. :slight_smile:

I’ve got following question:

If I load a file like this
[lua]local foo = require(“foo”) [/lua]
which has some local variables. Once i foo=nil it i thought it would be deleted by the GC…however it is still there when I “require” it again.

The only thing I could come up with is to use something like classes and instantiate an object of foo but since Lua is not really object oriented I can’t believe that there is no other way. I am sure there is an easy answer but I just can’t see it…

Cheers!
Alex [import]uid: 11772 topic_id: 5946 reply_id: 305946[/import]

huh, I’ve never thought about removing a required code file. I’ve been thinking of require() like an import statement in other languages, so I just require once at the top of my code and then don’t think about it further. Then any local variables in the module are essentially private static variables and I treat them as such (eg. manually resetting them when I need the value to reset.) [import]uid: 12108 topic_id: 5946 reply_id: 21201[/import]

Nil out package.loaded[“foo”]. Note that in some setups, require makes the table it uses for this private, and in those environments, you can’t allow Lua to release modules, but I don’t think Corona is one of those. [import]uid: 12678 topic_id: 5946 reply_id: 21567[/import]