On Sun, 16 Jun 2024, Sven Schreiber wrote:
Am 16.06.2024 um 15:00 schrieb Cottrell, Allin:
> "bL" is the name of a function, not a bundle, so "bL.L" is a
nonsense
> string. Is the following what you meant to write?
Whoops, this happened when trying to make the example as minimal as possible.
So here's a new variation of what I'm trying to show:
<hansl>
clear
function bundle embeddedlist(void)
series x = normal()
list L = x
return _(L)
end function
open denmark # just to have a dataset in place
bundle b = embeddedlist()
eval typename(b.L) # gives "matrix"
</hansl>
b.L is reported as a matrix at caller level because inside a bundle
it's just a vector of (putative) series ID numbers. If it turns out
that there are in fact series with those ID numbers at caller level,
the vector can be extracted as a list. But that's not the case here:
the series "x" inside the function has ID 5 (the next number after
IDE with ID 4 in the denmark dataset), and there's no series with
that ID at caller level.
To make available to the caller a series newly created within a
function you can return it as a series directly; or return a list
containing it directly; or put it into a bundle as a series; or put
it into a bundle as a column vector. (In the latter two cases the
caller will have to explicitly assign the bundle member to a
series.)
In principle we could modify the code that's executed when a bundle
is returned, such that we automatically push to the caller any new
series referenced by any lists inside the bundle. But I think that
would break the encapsulation we expect of hansl functions: "Hey,
this function was supposed to just return a bundle, but it's gone
and dumped a bunch of series into my dataset!" (Compare the case
where a function explicitly returns a list. This is obviously a
desirable facility; the caller knows what they're getting.)
Allin