Sorry, I'm a bit out of sync here, but anyway...
On Mon, 14 Jul 2008, Gordon Hughes wrote:
I would like to respond to Allin's note by drawing upon my
experience of writing a variety of functions over the last 2-3
weeks. In doing this I was aware of the dangers of overwriting
existing variables when returning a list of variables created in
the functions. Hence, I would certainly favour the separation
implied by the adoption of the PROTECT_LISTS 1 option.
Yes -- as Jack says, we really need that. There's a definite
design flaw in the current structure.
However, I find the explanation and/or the handling of lists
passed as function arguments rather clumsy. My point concerns
bullet 2 close to the end of the note plus the code fragment for
make_cubes. It appears to imply that whenever one passes a list
of series containing, say, the independent variables for an
estimation function it will be necessary to include a loop over
the list to copy the contents of this list to new variables
inside the function.
No. I guess I wasn't clear. So long as you're using a list _as_
a list (e.g. as an argument to a command such as ols, omit, print,
summary or whatever), there's no need to do anything special. The
internal representation of a list in gretl is an array of integers
(ID numbers of variables), and that's precisely what you get when
you accept a list argument to a function.
The new procedures I described (which are admittedly slightly
cumbersome) are needed only if you want to "unpack" a list and
operate on its elements individually. Well, in fact it's narrower
than that: only if you (a) need to know the name of a list member
or (b) need to use the values of a list-member on the right-hand
side of a genr-type command.
I gave the example of the cubes function because this is in a
sense the "worst case scenario" for the new mechanism. Many sorts
of uses of list arguments will be unaffected.
Allin.