On Sat, 20 Jun 2015, Riccardo (Jack) Lucchetti wrote:
On Fri, 19 Jun 2015, Allin Cottrell wrote:
> But the data are _not_ gone, or not after the change I made in February of
> this year. If you don't assign the return value of moo(), nothing changes
> in the caller's dataset. Or are you seeing something different?
Well, yes. If you run the code below (slight modification of the previous
version),
<hansl>
function list moo(void)
series you_would_think_this_is_safe = NA
list ret = you_would_think_this_is_safe
return ret
end function
# --- main -----------------------------
nulldata 10
# your precious data
you_would_think_this_is_safe = normal()
# your precious data
print you_would_think_this_is_safe
# apparently harmless function call
moo()
print you_would_think_this_is_safe
# data are gone!
</hansl>
then here's what you get:
<output>
? print you_would_think_this_is_safe
Full data range: 1 - 10 (n = 10)
2.43453 0.131361 -0.220725 -1.66478 0.692591 0.933474 0.830973
0.407995 -0.102742 -0.500323
# apparently harmless function call
? moo()
? print you_would_think_this_is_safe
Full data range: 1 - 10 (n = 0)
NA NA NA NA NA NA NA NA
NA NA
# data are gone!
</output>
There was a fleeting moment in yesterday's CVS (rev 1.986 of
geneval.c) when that would happen -- when I inadvertently committed an
experimental reversal of my change of February 2015.
But the data will not disappear with current CVS, where my February
change is reinstated (with a better comment). Since the return value
offered by moo() is not assigned to anything, the function-call has no
lasting effect.
Allin