octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Questions about eval


From: John W. Eaton
Subject: Re: Questions about eval
Date: Tue, 29 Jan 2019 16:14:58 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1

On 1/29/19 4:01 PM, Andrew Janke wrote:
> In Matlab, statements (including assignment) and compound expressions
> (multiple expressions joined by semicolons or commas) are allowed in
> eval. All your examples work.

Thanks.

> If you use the output-capturing form `x = eval(expr)` then it needs to
> be a single non-compound, non-assignment-statement expression.

Does this appear to be a restriction on parsing or evaluation? In other words, does something like

  x = eval ('y = 1')

fail to parse the assignment statement or does it perform the assignment to Y and then fail to assign anything to X because (as I remember anyway) assignments in Matlab are statements and do not produce values.

Similarly, if you try

  x = eval ('for i = 1:3, i, end')

does the error happen when parsing the for loop statement or after the loop is executed (no value to assign)?

jwe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]