Am 16.06.2024 um 18:37 schrieb Allin Cottrell:
On Sun, 16 Jun 2024, Sven Schreiber wrote:
...

Yep, I basically know all that. I'm also not exactly sure what I'd prefer in this case. But the point is that when leaving the function, the list inside the bundle becomes invalid, but nobody tells the user about this situation. Instead, you get type changes and other side effects that are only expected when you really know the internals of gretl. So perhaps what I'm trying to say is that some warning or error might be useful.

"Doctor, it hurts when I do this." "Well then, don't do that."
Hehe -- well, it all started because gretl has a one-element 'ylist' in its model bundle which I needed/wanted to imitate, not because I had this crazy idea in the first place...

I agree this is kinda complicated, but I think you're making it more complicated than it need be. A function writer who has read the chapter of the User's Guide on User-defined functions should know that if you return in a bundle a list that references series that are local to the function it will be little or no use to the caller: so don't do it. It's not really a matter of hidden "internals" but of documented behaviour -- but of course if the documentation isn't as clear as it should be, that ought to be rectified.

I just checked the chapter on user-defined functions and I cannot find that explanation. I presume that you are talking of the paragraph "Series and lists as bundle members" in the previous chapter on "Gretl data types", where functions aren't mentioned (and rightly so, at that point in the guide).

BTW, in that function-related chapter in the "Return values" section it says: "Having a function return a list or bundle is a way of permitting the “return” of more than one variable." Maybe the possibility of arrays could also be mentioned there.

thanks

sven
_______________________________________________
Gretl-devel mailing list -- gretl-devel@gretlml.univpm.it
To unsubscribe send an email to gretl-devel-le...@gretlml.univpm.it
Website: 
https://gretlml.univpm.it/postorius/lists/gretl-devel.gretlml.univpm.it/

Reply via email to