bugGNU Octave - Bugs: bug #42126, persistent variable inaccessible...

 
 

bug #42126: persistent variable inaccessible from within a nested function

Submitted by:  sergey plotnikov <nul0m>
Submitted on:  Tue 15 Apr 2014 05:05:05 PM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: ConfirmedAssigned to: None
Originator Name: Open/Closed: Open
Release: devOperating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

(Jump to the original submission Jump to the original submission)

Wed 28 Dec 2016 05:18:18 PM UTC, comment #6:

As a workaround until someone codes a fix fo this, the persistent variable can be changed to a global.

Rik <rik5>
Project Administrator
Wed 28 Dec 2016 04:29:16 PM UTC, comment #5:

This is marked as "Matlab Compatibility" because Octave is not, in fact, Matlab compatible. There is a separate classification for "WTF Matlab" when the MathWorks has done something super strange that is barely worth implementing. This is worth fixing.

Since Octave is a completely volunteer effort, the best way to get something fixed is to do it yourself or get someone else interested in the problem who can fix it.

Rik <rik5>
Project Administrator
Wed 28 Dec 2016 10:36:15 AM UTC, comment #4:

Just pointing out this bug was flagged recently on stackoverflow: stackoverflow.com/questions/41317608/nested-function-does-not-see-local-variable-in-octave-matlab so it's still alive and well after 2 years, and affecting real users.

I would say that describing this bug as a "Matlab Compatibility" issue is sugarcoating the issue a bit. This is clearly an octave bug relating to the implementation of nested functions; matlab is just doing what it's supposed to, this is not a "wtf matlab" moment.

Tasos Papastylianou <tpapastylianou>
Thu 15 Dec 2016 02:44:43 PM UTC, comment #3:

This issue is still present in Octave 4.2.0.

A function call to the function cited in comment #0 still throws an error in Octave.

Hartmut <hardy>
Wed 25 Nov 2015 09:57:04 PM UTC, comment #2:

Still present on the development branch (11/25/15).

Rik <rik5>
Project Administrator
Tue 15 Apr 2014 07:40:11 PM UTC, comment #1:

Confirmed on 3.8.1 & 4.1.0+ on WinXP
Although with different line numbers in the error messages - I suppose you didn't show the exact code :-)

Indeed this is documented ML behavior:
http://www.mathworks.nl/help/matlab/matlab_prog/share-data-between-workspaces.html,
see first sentence under "Nested functions".

Apparently this doesn't only hold for persistent vars but for all stuff in the parent's workspace.

OS set to "Any"

Philip Nienhuis <philipnienhuis>
Project Member
Tue 15 Apr 2014 05:05:05 PM UTC, original submission:

The following function works in Matlab but doesn't in Octave.

Below is the Octave error message:

Matlab has no problem accessing myVar when inside myNested(), so I'm wondering if current Octave behavior was really meant.

sergey plotnikov <nul0m>

 

(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 tpapastylianou (Posted a comment)
  • -unavailable- added by hardy (Posted a comment)
  • -unavailable- added by rik5 (Updated the item)
  • -unavailable- added by nul0m (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 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 24 Apr 2014 03:59:43 PM UTCrik5CategoryNone=>Interpreter
      Summarypersistent variable is inaccessible from within a nested function=>persistent variable inaccessible from within a nested function
    Tue 15 Apr 2014 07:40:11 PM UTCphilipnienhuisStatusNone=>Confirmed
      Operating SystemGNU/Linux=>Any

    Back to the top


    Powered by Savane 3.1-cleanup1