Fairy long, I'm afraid, but probably worth reading if you do a lot 
of scripting, particularly with lists or matrices.

In working on some scripts lately I've been building lists using 
the syntax

list foo = null
loop <something>
  ...
  list foo += varname
  ...
endloop

This works OK, but I kept forgetting to say "list foo += .." 
rather than just "foo += ...".  The result was an "unknown 
variable in command" error message, which I found confusing at 
first, then annoying.  (Appearing on the left-hand side of a 
genr-type expression, "foo" was not recognized as the name of 
anything, unless you prompted gretl to look for lists with the 
"list" keyword.)

So I've made a start on incorporating lists into the genr 
mechanism more fully.  You no longer have to repeat "list" in 
front of listnames, as above.  Once a list is created, you can add 
to it, subtract from it, or redefine it, just using its name.

While working in this area I discovered a bug or two in genr.  
For example, up till today, if you typed

  scalar x = 3 4

you'd get a scalar x with value 3 and no error message, despite 
the syntactically incorrect trailing " 4".  No more.  Now, one or 
more spaces between variables or constants in a genr formula (with 
no intervening operator or punctuation) has a specific meaning, 
namely, concatenation of list elements.  So, the following is OK:

  list xlist = 1 2 3
  xlist += 4 5 6

But "scalar x = 3 4" will produce an error: it's trying to assign 
a list to a scalar.

One side effect is worth noting.  According to the manual, the way 
to create a matrix out of data series is, e.g.,

  matrix m = { x1, x2, x3 }

with the names of the series separated by commas.  Up till now, 
however, this would also work:

  matrix m = { x1 x2 x3 }

This was just sloppiness, and it won't work any more.

The other bug I found was the possible masking of lists by scalars 
or series.  E.g.

  list X = x1 x2 x3
  X = log(x1)

The second command would go through without flagging any error: 
you'd get a variable named X, but the list named "X" would now be 
inaccessible.  This can't happen any more:

  open data4-10
  list X = 1 2 3
  X = log(ENROLL)
  > Data types not conformable for operation

However, if you replace the third line with

  list X = log(ENROLL)

you get the effect you might expect, namely, replacing the 
original list with a new one that has one element,
l_ENROLL.

There are no doubt some new issues introduced by this change
that will need to be hashed out.  But the warning I gave earlier
about the state of CVS related to breakage of previously valid 
uses of genr, and I believe that problem is now fixed.

Allin.

Reply via email to