On Tue, 29 Jun 2010, Sven Schreiber wrote:
a model table assignment inside a function doesn't work anymore
(where "anymore" means with recent cvs gretl and it used to work three
months ago -- I just checked on 1.9.0 on Windows and get the same error,
so maybe it was introduced between 1.8.7 and 1.9.0)
What I mean is something like this:
function void check(...)
mymodel <- tsls ...
end function
check()
gives an error "unknown command mymodel <- ..."
Or is this not supposed to work (anymore) in a function, I don't
remember?
Hmm, I think it's not supposed to work inside a function, on the
grounds that it breaks encapsulation. But if it worked earlier
then either the change should be reverted or it should go into the
log of backward-incompatible changes.
I wonder... might it be worth introducing for gretl 2.0 a "macro"
construct, alongside the (by now relatively heavy-duty) function
construct? I have in mind a very relaxed variant of a function,
which has access to everything at caller level. It could take
arguments and return stuff if wanted, but could accomplish useful
work without doing that.
I haven't thought this through fully but I'm thinking that it
wouldn't be very difficult to implement, and might make life
easier for people who are not writing function packages but just
trying to make a script more structured/modular.
Another (and probably easier) alternative might be to make a
distinction between functions that are part of a package and those
that are not, and to relax some restrictions (e.g. on adding stuff
to the model table) for the latter sort.
Allin