On Sun, 3 Jul 2016, Sven Schreiber wrote:
Am 02.07.2016 um 19:45 schrieb Allin Cottrell:
> On Sat, 2 Jul 2016, Riccardo (Jack) Lucchetti wrote:
>
>> a'b'
>>
>> * is equivalent to (a') * (b') in Ox, Gauss and Julia
>> * is illegal in Octave (which doesn't have, I think, the binary '
>> operator)
>>
>> so we're the exception. So I guess it's just another case of choice
>> between backward-compatibility and pragamtism.
>
> I take the point here, but changing gretl's behavior in this regard will
> not be trivial. Unary transpose is unique as an operator that appears to
> the right of its operand, and we cannot in general tell unary transpose
> from binary transpose-multiply without "look behind", which we don't
> have in our parser at present.
>
> I'll think about this some more, but I'm not going to attempt a change
> before the forthcoming release.
>
Absolutely it's better not to rush it. About the "look behind" stuff
I'm not
sure I understand. Currently I guess the parser already needs to decide
whether any "'" is unary or binary. Or do you mean that it's always
treated
as binary unless the next thing is a closing parentheses or the end of line?
(Although even then the "next thing" situation would imply some looking
behind.)
Ah, the inscrutable wonders of recursion! I finally figured out (or
rather, stumbled upon) the correct way of imposing right
associativity for a binary operator.
Previously we had a hack in place for the behavior of '^'
(exponentiation) and I tried duplicating that for
transpose-multiply, but then I realized that the hack was working
only to one level of nesting, so for example 2^3^2 would come out
right -- as 2^(3^2) -- but 2^3^2^1.5 would not, and similarly
for a'b' versus a'b'c'.
But a one-word change to the parser has fixed both operators for
arbitrary levels of nesting.
(On the point of distinguishing unary tranpose from binary
transpose-multiply, what we do is assume transpose-multiply until we
see that the following symbol, or absence of symbol, is inconsistent
with that interpretation, in which case we treat unary transpose as
a special case of transpose-multiply, inserting an empty node in
place of a right-hand matrix.)
Allin