mauede at alice.it
2009-Apr-29 15:17 UTC
[R] what happens if a function removes an external (global) variable ?
My program consists of a number of functions and a main script. It loops through many time series analyzing one at a time. I have declared a number of arrays and scalar variables in the main script namespace (using C++ terminology) because those data structures ar shared by many functions. let say "XX" is he name of a global array. I wonder what happens in the following cases: 1. a function tries to remove the global array through the instruction "rm(XX)" Will the next usage of XX still access a global variable (if using the assignment operator "<<-") or a new local one will be created ? 2. the main script removes the global array through the instruction "rm(XX)" Will the next usage of XX in the main script allocate a new global variable that can be accessed by all the called functions ? 3. If the global array XX is never removed but is assigned in different loops alternatively very short and very long time series then what will happen to the memory segment allocated to R ? Will it get more and more fragmented slowing down the process ... or aven crash ? Thank you very much. Maura tutti i telefonini TIM! [[alternative HTML version deleted]]