Am 25.05.2013 15:24, schrieb Allin Cottrell:
On Fri, 24 May 2013, Sven Schreiber wrote:
>>
>> Possibly, but your use of of sum() is definitely invalid. This
>> function requires a series or list argument, as per the
>> documentation.
>
> Actually I didn't write this line, but thanks for pointing this out --
> then I guess the question is why is gretl NOT complaining without the
> line wrapping?
Hmm, it seems that despite the limitation to a series or list
argument in the doc, in fact the sum() function accepts a row
or column vector argument, in which case it returns the sum of
the elements of the vector. What do we think: document that,
or ban it, in favor of using sumc() or sumr() as appropriate?
In the vector case I don't have strong feelings; while it would
sometimes be nice to be lazy and just use sum(), thinking about whether
one needs sumc() or sumr() may help to avoid bugs in the script by
getting your row and column vectors right. (OTOH, often a vector is just
a 1-dim array conceptually where you don't really care if it's a row or
col.)
But to be honest, there were some occasions in the past when I wished I
could just sum all the elements in a matrix with sum(m) -- sumr(sumc())
seems clunky. Up until today I have resisted the temptation to ask for
this, however...
But meanwhile, returning to the line-wrapping issue: when
functions are parsed and saved in a package, line-breaking via
the backslash character is eliminated -- we consolidate the
lines so they can be read in one go. There was a bug in the
method for doing this, but I believe that was fixed in CVS a
few weeks ago (on May 6, to be precise).
I tried creating a dummy package from a function containing
exactly the line you quoted above (with backslash break) and
it ran OK, no syntax error. So I suspect the bug report here
may be out of date.
Hm, I thought I had used the latest snapshot -- I will keep my eyes open
for this.
thanks,
sven