On 1/29/19 4:19 PM, Andrew Janke wrote:
> IIRC, the error happens at parse time, and eval balks at evaluating that
> code, giving you some sort of syntax error before any of it is evaluated.
OK.?
Since assignment in Octave does produce a value, I think we would want
to continue allowing
x = eval ('y = 1')
Error: Incorrect use of '=' operator. To assign a value to a variable, use '='. To compare values for equality, use '=='.
to also assign a value to X.
I thought that Octave allowed both of the following
x = eval ('y = 1; z = 2;')
Error: Incorrect use of '=' operator. To assign a value to a variable, use '='. To compare values for equality, use '=='.
x = eval ('for i = 1:3, i, end')
Error: Illegal use of reserved keyword "for".
to perform the evaluations, but I see that neither of these work in
current Octave and they also fail at when parsing. So I guess
compatibility here is already reasonably good.
My question about what to do for
eval (try_code, catch_code)
>> eval ('x=1', 'x=2')
x =
1
>> eval ('x=sin', 'x=2')
x =
2
remains. Does anyone have comments about that? If not, I can open a
bug report so that the issue is not forgotten.
jwe
The results above are from Matlab R2018b and except for "eval ('y = 1')" Octave 5.0.90 does almost the same.
So I think Octave should keep this eval (try_code, catch_code) too. (Btw. thanks I didn't know of this eval-feature ^^).
Best,
Kai