On Sun, 20 Jun 2021, Sven Schreiber wrote:
Am 20.06.2021 um 20:12 schrieb Allin Cottrell:
> On Sun, 20 Jun 2021, Sven Schreiber wrote:
>> minor follow-up issue: Doing "return dataset" in the function fails,
but
>> the more verbose two-liner works:
>>
>> list out = dataset
>>
>> return out
>>
>> So it kind of looks to me as if doing "return dataset" directly could
>> also be allowed syntax.
>
> My first thought is that "dataset" should not be allowed as a
> list-name inside a function.
Well, it does work already! I can understand why the special form should
not be over-stretched as in "return dataset", but then there might be
"return deflist(dataset)" (untested).
But seriously, there appear to be clear rules as to which series are
locally available inside a function. Why should 'dataset' be banned then
in that context?
According to the Guide, the "dataset" macro refers to "all the
series in the current dataset (except the pre-defined const)". In
general, within a function you do not have access to the entire
current dataset, and moreover some of the access you have may be
just "borrowed", so this is not applicable. It's like you're saying,
"Hey gretl, you figure out what should go into this list I want to
return!".
The hansl idioms for creating a list as return value from a function
are (a) create a named list via a single function call, or if that's
not feasible (b) start by defining a null list then sequentially
append the series in question.
Allin