On Sun, 28 Feb 2021, Riccardo (Jack) Lucchetti wrote:
On Sat, 27 Feb 2021, Allin Cottrell wrote:
> First reaction: I'd say this is a case for use of "catch" rather than
> having getinfo return an empty or bogus bundle. An on-the-fly series is
> just a raw array of doubles and it seems to me the only information gretl
> can provide about it is the numerical values. Well, I suppose we could get
> a rudimentary "description" by extracting the argument to getinfo itself as
> a string:
> getinfo(log(sqft)) -> description: "log(sqft)"
> But would that serve a purpose?
In fact, I guess it would. The use-case that prompted me to look into this is
using getinfo() within a function, eg
function void foo(series x)
b = getinfo(x)
# do things
To be more specific, I was using getinfo() to check whether the
series in input had some sort of description. Clearly, if you call
something like "foo(log(x))" the function breaks down. Like you
say, I could use the "catch" modifier, but for my taste the
catch/$error mechanism should be reserved for "true" errors (like
eg trying to invert a singular matrix) rather than what we have
here. In my view, the input series in this case has no meaningful
metadata, but not's unreasonable to ask for it.
The trouble, IMO, is this: the minimal description of an on-the fly
series with formula "log(x)" as "log(x)" would, at best, be
available to getinfo() only immediately after the series was
created, at the same level of function execution. Once such a series
is forwarded as a function argument, it becomes a citizen of the
callee's dataset, but there's no basis for a memory of how it was
As things stand, remembering the description of a series requires
that the series has an associated VARINFO struct, which is realized
only for series that have dataset membership. But an on-the-fly
series argument to a function acquires such membership only once it
is accepted as a valid argument -- which, it seems to me, is too
late to be of any use.
Of course, if you can suggest a feasible mechanism whereby this
could work, I'll happily stand corrected.