I am looking for a way to rewrite a Mathematica function which reads a text file of numerical values (several hundred Mb in size) and creates a Mathematica array out of it. I use ReadList to read the file and this goes as quickly as one could expect, but my problem is how do I get this array back out to a variable outside this function without it being copied or anything silly like that?
Currently my function is written like
LoadData[vars_...]:=Module[{localvars_...},...Return[giant array];];
and try to assign the giant array to a variable like this:
table = LoadData[vars_...]
However the time spent taking the array from "giant array" and putting it in "table" is longer than the file read itself. Clearly the whole thing is being copied or something silly; it will probably overflow the memory if I go to much larger data.
How can I prevent this happening? How can I get Mathematica to just rename the array rather than copy all the data? In case it is relevant, the function is defined in a separate package to the one where I am using it.
SOLVED:
Ahh, thanks belisarius, simple question on passing data between functions indeed gives me the hint I need, i.e. setting
Attributes[LoadData]={HoldFirst}
in the package seems to make the function behave sensibly.