Am 22.01.2011 18:46, schrieb Riccardo (Jack) Lucchetti:
On Sat, 22 Jan 2011, Sven Schreiber wrote:
For the sake of completeness, I wouldn't be against a "clear" command to
get rid of selected categories of items. Maybe we could spice up the
"delete" command a bit, like for example adding a --matrix option to
delete matrices only, etc.
yes, this sounds good too -- but to be clear, this was meant as a
workaround or second-best solution to the variable scope thing, not as a
main thing to push
>
> My point was not against strong typing in this context (although it
> helped to trigger the error here, of course). It would be fine if in the
> scope of the script the type of temp were fixed (strong typing). I'm
> pointing out the problems of the fact that the scope of the variable
> temp is automatically global, i.e. extends beyond the current script.
No, sorry, I don't like this at all. The "include" command must leave
objects alone. On a somewhat related subject: do we still want to keep
both "include" and "run" for 2.0?
when I wrote "current script" I meant the same thing as before, namely
the current top-level script which is executed; and this top-level scope
would still be in effect when including child scripts, functions etc.
>
> AFAICS this essentially would imply that *everything* needs to be
> wrapped inside functions. I don't think that would be good. Note I
> didn't *want* to make thiese variables global, but with gretl's current
> behavior I don't have a choice (if I don't want to wrap everything in a
> function); so I view your statement "keep global variables at a minimum"
> as supporting my point!
Not really. If you want to use something as a black box, yes.
IMHO it's absolutely clear that sometimes you want to have a black box.
You said it yourself, only that you then say "well, use functions".
Another solution would be to require script authors to do the garbage
collection themselves, i.e. issue the needed 'delete' statements. I was
arguing for a kind of automatic garbage collection by limiting the scope
of variables, maybe because I'm lazy. Also, that would probably require
the declaration of explicitly global variables. Perhaps the
disadvantages of those changes are too serious. Fair enough, I could
understand that. But it should be acknowledged that it is a real
limitation of gretl to have only global variables (apart from the
function scope), not to turn that around into a feature.
cheers,
sven