On Tue, 13 Feb 2018, Sven Schreiber wrote:
Hi, here's something that I find puzzling (snapshot Feb 7):
<hansl>
clear
catch eval sum(1) # error: "no dataset active"
catch scalar sc = sum(1) # ditto
open djclose.gdt
catch eval sum(djclose) # OK
catch eval sum(1) # weird printout of all values, almost like 'print 1'
catch scalar sc = sum(1) # error: "data types not matched"
catch scalar sc = sum(djclose) # OK
catch scalar sc = sum(1) # error: "sc is scalar, not acceptable"
</hansl>
I can understand the first two occurring "no dataset active" errors if gretl
interprets the '1' as a series ID which it cannot find.
But then: First the behavior yielding the weird printout looks like a bug.
Secondly, the final two different error messages is something I don't get.
sum() accepts a series, matrix or list argument. You can never refer
to series as such by ID number in gretl functions, only in commands.
However, "1" is a valid constructor for a list so that's how it's
interpreted, and under that interpretation the output is correct,
according to the documentation.
If there's a bug here, it would be accepting "1" as defining a
single-member list in the context of a function argument. Maybe
functions should accept only named lists, and an argument of "1" for
sum() should be flagged as a type error.
Allin