On Fri, 27 Jan 2017, Sven Schreiber wrote:
Am 27.01.2017 um 15:18 schrieb Marcin Błażejowski:
> W dniu 27.01.2017 o 14:52, Allin Cottrell pisze:
>> Hopefully this should
>> either confirm that gretl is right or expose a bug that we can fix.
> I got it.
> It's funny: the bug in code was like this: transpose(_matrix_) =
> transp(msortby(transp(_matrix_), 2)) and should be _matrix_ =
> transp(msortby(transp(_matrix_), 2)). However the first transp (on the
> left side) seems not working at all. I other words we found a bug which
> doesn't behave as bug.
> Hmmm...
You mean like this:
<hansl>
matrix m = 1
transp(m) = {0, 1; 2, 3}
print m # gives 1 (1x1)
</hansl>
The trouble here is that transp(m) is -- in C lingo -- "not an
lvalue". You cannot assign anything to the anonymous return value from
a function call.
However, it's OK to call a function and ignore the return value.
Gretl's command tokenizer gets as far as recognizing "transp" as the
name of a function and therefore passes the whole line to "genr",
thinking it might be such a case. Genr then sees that "transp(m)" is
not an lvalue, so the only sense it can make of the following "=" is
that it's supposed to be a test for equality.
BTW, the code on the experimental "gentest" branch in git calls
a syntax error for "transp(m) = {0, 1; 2, 3}". Part of the reason why
I want to ban "=" for "==" is that it'll be easier to get error
messages right. I mean, the correct error message here is simply that
transp(m) is not a valid left-hand side value, and that would come
through clearly if "=" was not accepted to mean "==".
Allin