[Gretl-devel] update on gretl functions and lists

Riccardo (Jack) Lucchetti r.lucchetti at univpm.it
Wed Jul 23 10:53:29 EDT 2008


On Wed, 23 Jul 2008, Allin Cottrell wrote:

> On Wed, 23 Jul 2008, Sven Schreiber wrote:
>
>> I see. But isn't it a bit incoherent (for lack of a better term)
>> to affect the outer scope when it comes to list members but not
>> when the list itself is involved? (By default, I mean.) IMHO it
>> would be more intuitive to have a similar default for all
>> arguments passed to a function. Maybe that would mean that
>> absence of 'const' would imply that the list itself could be
>> changed, instead of restoring the default.
>
> My (not perfectly comfortable) defence of the setup I describe
> above would run something like this: when you pass a plain series
> (not a series-pointer) to a function, the function can't modify
> the series at caller level.  The same for matrices and so on.  So
> lists should conform: you'd need a list-pointer to modify the list
> itself.  But part of the idea of a list argument is that the
> member series are made accessible as such (without any copying of
> values).  A list is a sort of "pointer to multiple series", which
> are therefore modifiable unless marked as const.

I'm ok with list contents being modifiable. This is conceptually distinct 
from the "inner naming" problem, which undermines the idea that the caller 
script *doesn't need to know* how a function internally computes its 
result. If you invoke a function with a list argument, you must be aware 
that the series in that list may come out modified. As Allin said, it's 
like a pointer to an array of series and as such is very useful, for 
example for mass-transforming a bunch of series. Note that the same 
happens with pointers anyway: if you call "foo(&y)" do you have any 
guarantee that y stays the same after foo has executed? Answer: no. So, I 
don't see the problem.

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

r.lucchetti at univpm.it
http://www.econ.univpm.it/lucchetti


More information about the Gretl-devel mailing list