I'm sparing gretl-users the gory detail ;-)
On Sat, 14 Mar 2015, Sven Schreiber wrote:
Am 14.03.2015 um 15:15 schrieb Allin Cottrell:
> On Sat, 14 Mar 2015, Sven Schreiber wrote:
>>>> list X=dummify(Z5) --drop-first
>>> "
>>
>> Remark for Allin and Jack:
>> BTW, I think the error message is strange insofar as IMO the parser
>> should complain already about the "--" in there, not about the
"drop"
>> word, no? But perhaps this has been changed since last release.
>
> The "--" is in principle OK if interpreted as "minus minus", as
in "y =
> f(x) --a".
Right. So if by coincidence "drop" and "first" were both existing
scalars (or even series?) then no error would be issued and the
expression would be read as:
list X = dummify(Z5) + drop - first
Because "drop" and "first" are not reserved words AFAICS. Maybe
I'm
being paranoid, but somehow this makes me nervous...
Yes, the statement would be read pretty much as you say. However,
"drop" and "first" will not be the names of series in the list
created by dummify(Z5), nor in fact by any invocation of dummify().
What if they're the names of scalars? Well, it's possible to cook up
a case where something of the sort appears to "work":
<hansl>
open data4-1
list X = 1 2 3
list X print
scalar drop = -4
scalar first = 3
list Y = X --drop-first
list Y print
</hansl>
This actually exposes a little bug. The "+" operator is not
recognized for adding a term to a list (simple concatentation is how
that's supposed to work), but when it's disguised as "--" it somehow
slips through, although it doesn't have the effect of adding series
number 4 to list Y. I'll take a look at fixing that.
On your broader point -- something that's really an error from the
user's point of view may under certain conditions go through as a
totally unintended command -- well, I think that's the price to be
paid for flexibility. I don't think we want to be saying to users
"Did you really mean minus minus?"
Allin