On Thu, 25 Jan 2007, Allin Cottrell wrote:
The main issue is this: although packages exist, there is a
completely "flat" namespace for user-defined functions in gretl
right now. This has various undesirable consequences...
I've just commmitted to CVS some fixes for this. Now each
function package is assigned an ID number using (as Sven
suggested) the system time.
Suppose two function packages X and Y contain private functions
with the same name (say, "foo"). Now that should not be a
problem: when the functions are loaded into memory we record the
ID of the package to which they belong. When "foo" is called from
within package X's main function we look up X's foo; if "foo" is
called from within Y we look up Y's foo (and so on recursively if
helper functions call other helper functions).
In a similar way, deleting package Y should result in the deletion
of Y's foo, but not X's.
There's one related issue I'll mention. We want to ensure that
(a) all gretl function _packages_ have unique names, and (b) that
these names correspond to the package's public interface (with
".gfn" appended). To help enforce this I've removed the "Save As"
button from the function package editor -- it seems to me that
button was inviting problems. In addition, if you make a new
package with public interface "somefunc", then go to Save, you'll
be prompted to save as "somefunc.gfn" (with a choice of which
directory to save to). If you overwrite the suggested .gfn name,
so that it no longer matches the public interface, you'll get an
error message.
Also related: when you're editing a function package you can edit
the code of the functions it contains, but you can't change the
names of those functions. In the (I hope) fairly unlikely case
that you want ro redo a function package, renaming the member
functions, you'll have to do something like this:
* Load the original package.
* "Edit" the original package and call up its code
* Copy and paste the code you want to a script window
* Rename the functions in the script, and run the script
* Create a new package that bundles the renamed functions
This is not supposed to be particularly easy, because messing
around with function names in existing packages would create a big
programming headache.
All the new code mentioned above is tested to some degree, but not
very extensively. If people can beat on it that would be very
helpful.
Allin.