On Mon, 7 Apr 2025, Sven Schreiber wrote:
Am 07.04.2025 um 20:21 schrieb Cottrell, Allin:
> Here's a further response to Sven after doing some more investigation.
> It's unlikely to be of interest to anyone who's not in the business of
> writing packaged functions that key off models represented in windows
> in the gretl GUI.
>
> The key question is this: under what conditions does gretl, inside a
> function, "know about" series that exist at the level from which the
> function was called? The answer:
>
> 1) Obviously, gretl knows about series that were explicitly passed as
> arguments.
>
> 2) In addition, gretl knows about series that are referenced in a
> "list" passed as an argument. Such series are temporarily
"localized"
> to the function, then returned to their original level when the
> function returns.
>
> 3) As an extension of point 2, we also temporarily "localize" series
> that are referenced in a list contained in a bundle passed as an
> argument to the function in question.
>
> And that's all.
Hm, what about $xlist, $uhat and all that in a packaged function from a model
window, not accessed through $model but directly in their own right? Would
that count as (3b)?
No, I'm afraid not. Membership in a list that is not provided as an
argument either directly or via a bundle argument, does not confer
visibility on "external" series inside a function.
> What Sven was trying to do would work if and only if
> we also "localize" series referenced in a list contained in a bundle
> that's _not_ passed as an argument but is made available within the
> function via the $model accessor -- something we have not attempted to
> date.
OK, but two questions remaining:
1) See my other email some minutes ago: the listmaker example with list "L =
m.xlist - m.instlist" seems to do just that, no?
No, that's just a matter of subtracting one given list (vector of
ints) from another. It doesn't require any access to the actual
series content. Your example requires such access, if gretl is to
realize that series 5 and 6 already contain the requested lags of
LRM.
2) There's still the weirdness of my OP that it did work when I
called my
other function rhslags() which shouldn't have changed anything AFAICS.
By passing the $model bundle as an argument to another (arbitrary)
function you made its list contents visible, and they remained
visible after that function returned.
Allin