bugGNU Octave - Bugs: bug #46397, eval: The evaluated code should...

 
 

bug #46397: eval: The evaluated code should not affect last result

Submitted by:  Oliver Heimlich <oheim>
Submitted on:  Sat 07 Nov 2015 12:14:23 PM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: Wont FixAssigned to: None
Originator Name: Oliver HeimlichOpen/Closed: Closed
Release: 4.0.0Operating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat 02 Sep 2017 08:28:56 PM UTC, comment #3:

Agree with "Won't Fix"
Someone might file a bug report to Mathworks on their
behavior.

Michael Godfrey <godfrey>
Project Member
Sat 02 Sep 2017 12:54:55 PM UTC, comment #2:

I'm marking this as "Won't Fix". It is a Matlab incompatibility, but it also makes more sense to me to kee it this way. 'eval' runs code that can have side effects. For example, you can bring new variables into existence with

It makes sense to me that a successful evaluation of code is the same as if the code had been typed, or run from a script, in which case the ans variable would be updated.

Rik <rik5>
Project Administrator
Sat 07 Nov 2015 03:07:20 PM UTC, comment #1:

The following algorithm should do the trick:

1. Store the state of `ans` in the target context (caller or base).

2. Evaluate the script.

3. Use the current state of `ans` in the target context as the return value for eval (or evalin).

4. Reset the state of `ans` in the target context to the value stored in step 1.

Oliver Heimlich <oheim>
Sat 07 Nov 2015 12:14:23 PM UTC, original submission:

When evaluating code with `eval`, this also affects what will be returned by the function `ans` afterwards. In Matlab this is not the case.

The function `evalin` is also affected.

Oliver Heimlich <oheim>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by godfrey (Posted a comment)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by oheim (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 02 Sep 2017 12:54:55 PM UTCrik5StatusNone=>Wont Fix
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1