On Sun, 21 Jun 2015, Sven Schreiber wrote:
Am 21.06.2015 um 10:53 schrieb Allin Cottrell:
>
> Sven, you're misunderstanding how "returning a list" works in hansl.
No I don't, everything you explain was actually how I already thought
things worked.
OK, then maybe I can explain my thinking better by reference to
Ignacio's HoltWinters package discussed elsethread.
What you're effectively saying is:
1) If the caller assigns a new list name it's all her fault if something
goes wrong. (I'm actually fine with this, though we can --and have--
talked about design changes that would improve the situation.)
Yes, more or less, though I'd say it's either the user's fault
(assuming the function in question is properly documented) or the
function author's fault (otherwise).
2) But a caller who calls the function anonymously somehow cannot be
expected to act responsibly and thus deserves special care.
No, that's not my view. Take HoltWinters. This function does some
computations, prints out some statistics, and also offers a list
return that wraps a couple of series. Maybe I'd like to see the
statistics but don't care to accept the generated series, so I don't
assign the return value. Before my code modification of February, I'd
have got the two series added to my dataset regardless. Surprise!
That's not Ignacio's fault, as I see it; it was gretl's fault.
With this sort of function, adding the series to the main dataset
should be conditional on accepting the list return, not because we
think the user is a dummy, but because it's a reasonable expectation
that if you don't want and don't ask for the series, you won't get
them.
Consider by contrast a built-in such as log(), applied to a list. This
function does absolutely nothing apart from creating logs of the input
series, and offering as return a wrapper for the generated series.
Unlike HoltWinters there's never any reason to call such a function
unless you want the series it generates. However, you don't
necessarily need the list wrapper. It therefore seems a legitimate
use-case to call log() without assignment in the expectation that the
series you want will be added; otherwise
log(List)
would just be a no-op.
Q: "Why did the logs get added to my dataset when I didn't assign the
return?" A: "Well, if you didn't want that then why did you call
log()?" The answer here seems to me to have force, but it doesn't have
force for HoltWinters, or other contributed functions that print
things or plot things besides offering a list return.
Allin