On Fri, 21 Jan 2011, Sven Schreiber wrote:

> Hi,
>
> I'm having a problem with what may be called variable "lifetime" or
> scope. Consider the two trivial scripts:
>
> <script1>
> scalar temp = 1
> </script1>
>
> <script2>
> matrix temp = muniform(2,1)
> </script2>
>
> If I run both of them in this order, the second one gives an error,
> apparently because gretl doesn't like to put a matrix result into the
> scalar variable temp.
>
> Is this a reasonable behavior? If the commands were executed in a single
> console session or in a single file (including further called files or
> functions), I think yes. But if the commands live in separate script
> files that just happen to be executed in the same gretl session, I tend
> to think that gretl should do some sort of garbage collection when the
> end of a (main driver) script is reached. Or is it the official policy
> that the user should do a 'delete temp' at the end of any such script?
>
> (BTW, I know that the 'open' command clears gretl's workspace, which
> would probably be the solution here. But I find myself doing more and
> more with gretl's nice matrix language without opening datafiles. So
> maybe a 'clear' command is needed?)

A few remarks:

* We don't have "clear", which would probably be nice, but we have 
"nulldata": "nulldata 2" probably does what you want.

* The relative merits of strong typing vs weak typing will always be an 
object for discussion. I personally prefer strong typing, but I concede 
that in a world where the most popular matrix-oriented languages are 
weakly-typed perhaps you have a point.

* I would guess that if you have scripts that are meant to be run one 
after another with little or no editing, perhaps you ought to use 
functions and keep the usage of global variables at a minimum. Perhaps 
bundles may help too.



Riccardo (Jack) Lucchetti
Dipartimento di Economia
Università Politecnica delle Marche

r.lucchetti(a)univpm.it
http://www.econ.univpm.it/lucchetti

Reply via email to