On Tue, 2 May 2017, Sven Schreiber wrote:
Am 26.01.2017 um 23:00 schrieb Allin Cottrell:
> On Thu, 26 Jan 2017, Sven Schreiber wrote:
>>
>> <hansl>
>> matrix heyho = ("a" == "b") ? garbl[3,] : I(2)
>> </hansl>
>>
>> There is no object "garbl", but that's by design in the case that
the
>> condition isn't true. Gretl says "[" would be invalid here.
>
> That's because '[' is accepted the by parser only if it's preceded by
the
> name of an object of a type that can be subsetted. We don't actually
> evaluate the LHS of a ternary expression if the antecedent is false, but we
> always have to parse it. There may be some way around this, but the
> practical answer is: use "if" in this sort of case.
Just a quick follow-up: I stumbled over a similar issue again (in my
johansensmall.gfn package), and given your response the workaround is clear.
But I noticed that the error message (with 2017a) is that (the equivalent of)
the symbol "garbl" is undefined, whereas above/before I had reported the
error to be "[ invalid". Don't know if that has a deeper meaning or if
it's
expected for you.
Well, I thought that was an improvement in the error message. But
maybe it isn't. I suppose a really explicit message would have to be
something like
Can't make sense of "garbl[..." since the symbol "garbl" is
undefined.
Allin