BTW, this is discussed in section 3.2.1 of "The R Language Definition".
Duncan Murdoch
On 2024-12-02 10:56 a.m., Mikael Jagan wrote:
I wonder if there is room for improvement here:
> str2lang("if (a) b1else b0")
if (a) b1 else b0
> str2lang("if (a) b1 \n else b0")
E
This is well known, and it's necessary for reasonable behaviour in an
interactive context. Imagine typing the code you were parsing. The
first line is
if (a) b1
At this point, the interpreter can't know that an else clause is coming.
Since the interpreter evaluates statements when they ar
I wonder if there is room for improvement here:
> str2lang("if (a) b1else b0")
if (a) b1 else b0
> str2lang("if (a) b1 \n else b0")
Error in str2lang("if (a) b1 \n else b0") : :2:2: unexpected 'else'
1: if (a) b1
2: else
^
It only occurs at top level. When t
Thanks - that makes sense. It's also documented in help("if"), so it's
doubly clear now that I did not do my homework here.
Mikael
On 2024-12-02 11:09 am, Duncan Murdoch wrote:
BTW, this is discussed in section 3.2.1 of "The R Language Definition".
Duncan Murdoch
On 2024-12-02 10:56 a.m., Mi