This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
CoolisTheName007's profile picture

[SOLVED][1.3][SMP/SSP]When program terminates namespace is reachable from Lua interpreter

Started by CoolisTheName007, 16 October 2012 - 04:32 PM
CoolisTheName007 #1
Posted 16 October 2012 - 06:32 PM
ComputerCraft Version Information: 1.3 Client / 1.3 Server

Description of Bug:
After running any program, the program's namespace, eg. functions, variables ect is accessible from the Lua interpreter.

Steps to Reproduce Bug:
Run a program, e.g. save 'var=3' as test, run test, enter the lua interpreter, and type var and enter.
I don't know if it this is intended, but it seems out of character for such a clear language as Lua.
Doyle3694 #2
Posted 16 October 2012 - 06:35 PM
don't post a bug of a depreciated version. atleast test if the bug exists in the recommended version(1.41)

Tekkit I guess?

After looking this through, this is not even a bug. everything that you run gets put on the RAM kinda(don't really know if it's the RAM but it's a close reference) and it's accesible until you restart the computer
ardera #3
Posted 16 October 2012 - 06:38 PM
I think thats normal, because the var3 is global and you can reach it from all programs (like the lua program)
To remedy that, only put a 'local' before the variable declaration
GopherAtl #4
Posted 16 October 2012 - 06:39 PM
Globals persist after programs terminate, that's how globals work. If its a problem make the variables and functions local.

Edit: ninja'd!
faubiguy #5
Posted 16 October 2012 - 06:40 PM
This is intended. If you assign a variable without the local keyword, it is assigned in the global scope, and is accessible from anywhere in the lua environment until the computer reboots, or its set to nil. If you want a variable to be deleted after a program exits, use local var=3.
CoolisTheName007 #6
Posted 16 October 2012 - 10:31 PM
Thanks, I know how to declare local variables, I just though that each program got a separate namespace. Adding the solved bracket to the topic. EDIT: how do I add it? Or isn't it me who should do it?
GopherAtl #7
Posted 17 October 2012 - 02:51 AM
after clicking edit you have to click the "use full editor" button below the post to be able to edit the topic.